2006-08-31 Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
authorMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Thu, 31 Aug 2006 11:00:41 +0000 (11:00 +0000)
committerMichael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
Thu, 31 Aug 2006 11:00:41 +0000 (11:00 +0000)
* debian/changelog:
* hildon-widgets/hildon-defines.c: Disconnect the signal before
attaching a new one -- prevents signals from being emitted two times,
fixes a memory leak. Fixes #NB26114.

ChangeLog
debian/changelog
hildon-widgets/hildon-defines.c

index 3735ea7..9b138d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2006-08-31  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
 
+       * debian/changelog: 
+       * hildon-widgets/hildon-defines.c: Disconnect the signal before
+       attaching a new one -- prevents signals from being emitted two times,
+       fixes a memory leak. Fixes #NB26114.
+
+2006-08-31  Michael Dominic Kostrzewa  <michael.kostrzewa@nokia.com> 
+
        * debian/changelog:
        * hildon-widgets/hildon-wizard-dialog.c: Changing the orded of the
        buttons in the wizard dialog to be: finish, previous, next, cancel.
@@ -17,7 +24,7 @@
        [Merging 0.13.1 => TRUNK]
 
        * ./: Merging the experimental color selector branch. Fixes: #NB37010,
-       #NB38559, #33217, #NB37172.   
+       #NB38559, #NB33217, #NB37172.   
        Maintainer change:
        Michael Dominic Kostrzewa
        <michael.kostrzewa@nokia.com>
index 5c5983b..9c4c798 100644 (file)
@@ -9,16 +9,19 @@ hildon-libs (0.14.0) unstable; urgency=low
   * fixes NB#37172 - Colour selector for background color shows logical string
   * fixes NB#37467 - Hildon name password dialog with autocapitalization
   * fixes NB#34613 - 'Cancel' and 'Finish' in wrong order in Wizard widget
+  * fixes NB#26114 - hildon_gtk_widget_set_logical_* leak signals
 
   * Merging the new color selector branch (0.13.1) with the main trunk code.
   * Maintainer change: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
   * Correcting the license headers
   * Removing the redundant files
   * Allowing menus to be removed from windows by passing NULL to set_menu
-  function (documented).
+    function (documented).
   * Removing the Johan's new key handling (introduced in 0.13.1.3) for the
-  time being. That requires a fix at a different level.
+    time being. That requires a fix at a different level.
   * Changing the order of the buttons in the wizard dialog
+  * Disconnect the previous notification signal before connecting the new one
+    (hildon_gtk_widget_set_logical_*)
 
  -- Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>  Wed, 30 Aug 2006 14:30:00 +0300
 
index c3ba664..ac72ae3 100644 (file)
@@ -168,7 +168,8 @@ static void hildon_logical_data_free (HildonLogicalData *ld)
  * 
  * This function assigns a defined logical font to the @widget and all its child widgets.
  * It also connects to the "style_set" signal which will retrieve & assign the new font for the given logical name each time the theme is changed.
- * The returned signal id can be used to disconnect the signal.
+ * The returned signal id can be used to disconnect the signal. 
+ * The previous signal (obtained by calling this function) is disconnected automatically and should not be used. 
  * 
  * Return value : The signal id that is triggered every time theme is changed. 0 if font set failed.
  **/
@@ -187,15 +188,16 @@ gulong hildon_gtk_widget_set_logical_font (GtkWidget *widget, const gchar *logic
   ld->logicalcolorstring = NULL;
   ld->logicalfontstring = g_strdup(logicalfontname);
 
+  /* Disconnects the previously connected signals. That calls the closure notify
+   * and effectively disposes the allocated data (hildon_logical_data_free) */
+  g_signal_handlers_disconnect_matched (G_OBJECT (widget), G_SIGNAL_MATCH_FUNC, 
+                                        0, NULL, NULL, 
+                                        G_CALLBACK (hildon_change_style_recursive_from_ld), NULL);
+
   /* Change the font now */
   hildon_change_style_recursive_from_ld (widget, NULL, ld);
 
-  /* Connect to "style_set" so that the font gets changed whenever theme changes.
-
-     FIXME: if this function is called multiple times, the old signal
-     handler should be disconnected. However since signal ID is
-     returned, this probably can't be done without breaking backwards
-     compatibility. */
+  /* Connect to "style_set" so that the font gets changed whenever theme changes. */
   signum = g_signal_connect_data (G_OBJECT (widget), "style_set",
                                   G_CALLBACK (hildon_change_style_recursive_from_ld),
                                   ld, (GClosureNotify) hildon_logical_data_free, 0);
@@ -213,6 +215,7 @@ gulong hildon_gtk_widget_set_logical_font (GtkWidget *widget, const gchar *logic
  * This function assigns a defined logical color to the @widget and all it's child widgets.
  * It also connects to the "style_set" signal which will retrieve & assign the new color for the given logical name each time the theme is changed.
  * The returned signal id can be used to disconnect the signal.
+ * The previous signal (obtained by calling this function) is disconnected automatically and should not be used. 
  * 
  * Example : If the style you want to modify is bg[NORMAL] then set rcflags to GTK_RC_BG and state to GTK_STATE_NORMAL.
  * 
@@ -233,12 +236,17 @@ gulong hildon_gtk_widget_set_logical_color (GtkWidget *widget, GtkRcFlags rcflag
   ld->state = state;
   ld->logicalcolorstring = g_strdup(logicalcolorname);
   ld->logicalfontstring = NULL;
+
+  /* Disconnects the previously connected signals. That calls the closure notify
+   * and effectively disposes the allocated data (hildon_logical_data_free) */
+  g_signal_handlers_disconnect_matched (G_OBJECT (widget), G_SIGNAL_MATCH_FUNC, 
+                                        0, NULL, NULL, 
+                                        G_CALLBACK (hildon_change_style_recursive_from_ld), NULL);
   
   /* Change the colors now */
   hildon_change_style_recursive_from_ld (widget, NULL, ld);
 
-  /* Connect to "style_set" so that the colors gets changed whenever theme
-     changes. FIXME: same as above */
+  /* Connect to "style_set" so that the colors gets changed whenever theme */
   signum = g_signal_connect_data (G_OBJECT (widget), "style_set",
                                   G_CALLBACK (hildon_change_style_recursive_from_ld),
                                   ld, (GClosureNotify) hildon_logical_data_free, 0);