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
This commit is contained in:
Alan Jenkins 2016-10-12 16:38:13 +01:00 committed by Matthias Clasen
parent 3731da14a0
commit 982c4a70b6

View File

@ -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);