[gtk+] GtkHeaderBar: Don't leak



commit 3289b3efbf336db33f869a11f82fed2765ad5a0e
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 19 20:35:28 2013 -0400

    GtkHeaderBar: Don't leak
    
    Should have a finalize function, if there's strings to free.
    Also avoid some pointless extra ref on custom title widgets.

 gtk/gtkheaderbar.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 3058c9e..88bc1ab 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -682,12 +682,11 @@ gtk_header_bar_set_custom_title (GtkHeaderBar *bar,
 
       priv->custom_title = NULL;
       gtk_widget_unparent (custom);
-      g_object_unref (custom);
     }
 
   if (title_widget)
     {
-      priv->custom_title = g_object_ref (title_widget);
+      priv->custom_title = title_widget;
 
       gtk_widget_hide (priv->label);
 
@@ -727,6 +726,16 @@ gtk_header_bar_get_custom_title (GtkHeaderBar *bar)
 }
 
 static void
+gtk_header_bar_finalize (GObject *object)
+{
+  GtkHeaderBar *bar = GTK_HEADER_BAR (object);
+
+  g_free (bar->priv->title);
+
+  G_OBJECT_CLASS (gtk_header_bar_parent_class)->finalize (object);
+}
+
+static void
 gtk_header_bar_get_property (GObject    *object,
                              guint       prop_id,
                              GValue     *value,
@@ -1048,6 +1057,7 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
 
+  object_class->finalize = gtk_header_bar_finalize;
   object_class->get_property = gtk_header_bar_get_property;
   object_class->set_property = gtk_header_bar_set_property;
 


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