diff options
author | Kalev Lember <klember@redhat.com> | 2015-12-07 17:21:51 +0100 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-01-27 21:49:49 -0500 |
commit | e3fb59f88c80d37af4a3f6ccc474cc1d26e20266 (patch) | |
tree | 4b73473d976cd849bd1c5130c2546673d3988aeb /gtk | |
parent | 5c9c3ccbd046d9027d85cb959722d771d6ca7f7c (diff) | |
download | gtk+-e3fb59f88c80d37af4a3f6ccc474cc1d26e20266.tar.gz |
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
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkheaderbar.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c index 555d513bbb..7fe47f744e 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; |