[gtk+/gtk-3-18] headerbar: Don't leak internal widgets



commit e3fb59f88c80d37af4a3f6ccc474cc1d26e20266
Author: Kalev Lember <klember redhat com>
Date:   Mon Dec 7 17:21:51 2015 +0100

    headerbar: Don't leak internal widgets
    
    Make sure to clean up internal widgets in destroy, as these aren't
    cleaned up when GtkContainer walks the childrens list in
    gtk_container_destroy().
    
    This also fixes a gedit crash as reported in
    https://bugzilla.redhat.com/show_bug.cgi?id=1288669
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759132

 gtk/gtkheaderbar.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 555d513..7fe47f7 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -1392,6 +1392,40 @@ gtk_header_bar_get_custom_title (GtkHeaderBar *bar)
 }
 
 static void
+gtk_header_bar_destroy (GtkWidget *widget)
+{
+  GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget));
+
+  if (priv->custom_title)
+    {
+      gtk_widget_unparent (priv->custom_title);
+      priv->custom_title = NULL;
+    }
+
+  if (priv->label_box)
+    {
+      gtk_widget_unparent (priv->label_box);
+      priv->label_box = NULL;
+    }
+
+  if (priv->titlebar_start_box)
+    {
+      gtk_widget_unparent (priv->titlebar_start_box);
+      priv->titlebar_start_box = NULL;
+      priv->titlebar_start_separator = NULL;
+    }
+
+  if (priv->titlebar_end_box)
+    {
+      gtk_widget_unparent (priv->titlebar_end_box);
+      priv->titlebar_end_box = NULL;
+      priv->titlebar_end_separator = NULL;
+    }
+
+  GTK_WIDGET_CLASS (gtk_header_bar_parent_class)->destroy (widget);
+}
+
+static void
 gtk_header_bar_finalize (GObject *object)
 {
   GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (object));
@@ -1844,6 +1878,7 @@ gtk_header_bar_class_init (GtkHeaderBarClass *class)
   object_class->get_property = gtk_header_bar_get_property;
   object_class->set_property = gtk_header_bar_set_property;
 
+  widget_class->destroy = gtk_header_bar_destroy;
   widget_class->size_allocate = gtk_header_bar_size_allocate;
   widget_class->get_preferred_width = gtk_header_bar_get_preferred_width;
   widget_class->get_preferred_height = gtk_header_bar_get_preferred_height;


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