[gtk+] Don't leak a ref to the settings



commit 8a9a3949ddb4238444339426c9a82412299f2b83
Author: William Jon McCann <jmccann redhat com>
Date:   Wed Sep 12 09:08:28 2012 -0400

    Don't leak a ref to the settings
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683896

 gtk/gtktoolbar.c       |   10 +++++++++-
 gtk/gtktoolitemgroup.c |    9 +++++++++
 gtk/gtktoolpalette.c   |    9 +++++++++
 3 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index 69fd2b3..e184c06 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -2091,7 +2091,7 @@ gtk_toolbar_screen_changed (GtkWidget *widget,
   if (old_settings)
     {
       g_signal_handler_disconnect (old_settings, priv->settings_connection);
-
+      priv->settings_connection = 0;
       g_object_unref (old_settings);
     }
 
@@ -3122,6 +3122,14 @@ gtk_toolbar_dispose (GObject *object)
       priv->menu = NULL;
     }
 
+  if (priv->settings_connection > 0)
+    {
+      g_signal_handler_disconnect (priv->settings, priv->settings_connection);
+      priv->settings_connection = 0;
+    }
+
+  g_clear_object (&priv->settings);
+
  G_OBJECT_CLASS (gtk_toolbar_parent_class)->dispose (object);
 }
 
diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c
index b61e1a1..5907bf4 100644
--- a/gtk/gtktoolitemgroup.c
+++ b/gtk/gtktoolitemgroup.c
@@ -229,6 +229,7 @@ gtk_tool_item_group_screen_changed (GtkWidget *widget,
   if (old_settings)
   {
     g_signal_handler_disconnect (old_settings, priv->settings_connection);
+    priv->settings_connection = 0;
     g_object_unref (old_settings);
   }
 
@@ -519,6 +520,14 @@ gtk_tool_item_group_dispose (GObject *object)
       priv->toplevel = NULL;
     }
 
+  if (priv->settings_connection > 0)
+    {
+      g_signal_handler_disconnect (priv->settings, priv->settings_connection);
+      priv->settings_connection = 0;
+    }
+
+  g_clear_object (&priv->settings);
+
   G_OBJECT_CLASS (gtk_tool_item_group_parent_class)->dispose (object);
 }
 
diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c
index 9d8cd04..1503276 100644
--- a/gtk/gtktoolpalette.c
+++ b/gtk/gtktoolpalette.c
@@ -383,6 +383,14 @@ gtk_tool_palette_dispose (GObject *object)
       palette->priv->text_size_group = NULL;
     }
 
+  if (palette->priv->settings_connection > 0)
+    {
+      g_signal_handler_disconnect (palette->priv->settings, palette->priv->settings_connection);
+      palette->priv->settings_connection = 0;
+    }
+
+  g_clear_object (&palette->priv->settings);
+
   G_OBJECT_CLASS (gtk_tool_palette_parent_class)->dispose (object);
 }
 
@@ -932,6 +940,7 @@ gtk_tool_palette_screen_changed (GtkWidget *widget,
   if (old_settings)
   {
     g_signal_handler_disconnect (old_settings, priv->settings_connection);
+    priv->settings_connection = 0;
     g_object_unref (old_settings);
   }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]