[gtk+/gtk-3-22] headerbar: fix leak of label_sizing_box



commit 29fbeea84d338d71a0257b93b1c2654ca3779e60
Author: Alan Jenkins <alan christopher jenkins gmail com>
Date:   Wed Oct 12 16:38:13 2016 +0100

    headerbar: fix leak of label_sizing_box
    
    Since the widget is not added to a container, we have the responsibility
    to sink the initial floating reference, and ultimately to unref it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772859

 gtk/gtkheaderbar.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 40f5d3d..e467326 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -133,8 +133,9 @@ init_sizing_box (GtkHeaderBar *bar)
    * the real label box with its actual size, to keep it center-aligned
    * in case we have only the title.
    */
-  priv->label_sizing_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
-  gtk_widget_show (priv->label_sizing_box);
+  w = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_widget_show (w);
+  priv->label_sizing_box = g_object_ref_sink (w);
 
   w = gtk_label_new (NULL);
   gtk_widget_show (w);
@@ -1466,6 +1467,12 @@ gtk_header_bar_destroy (GtkWidget *widget)
 {
   GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (GTK_HEADER_BAR (widget));
 
+  if (priv->label_sizing_box)
+    {
+      gtk_widget_destroy (priv->label_sizing_box);
+      g_clear_object (&priv->label_sizing_box);
+    }
+
   if (priv->custom_title)
     {
       gtk_widget_unparent (priv->custom_title);


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