listbox: Manually unparent placeholder in dispose
authorTimm Bäder <mail@baedert.org>
Thu, 11 May 2017 13:33:13 +0000 (15:33 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 11 May 2017 19:01:42 +0000 (15:01 -0400)
We can't make the placeholder a non-internal child as that breaks
applications that previously relied on foreach() to only return
GtkListBoxRow instances. Instead, unparent the placeholder manually in
dispose.

https://bugzilla.gnome.org/show_bug.cgi?id=782494

gtk/gtklistbox.c

index f16e02aff86ae72f2a18a98f49547546b05bdb56..702e3424ccf20d061bece76f61f66bcedd2d7a76 100644 (file)
@@ -408,6 +408,20 @@ gtk_list_box_finalize (GObject *obj)
   G_OBJECT_CLASS (gtk_list_box_parent_class)->finalize (obj);
 }
 
+static void
+gtk_list_box_dispose (GObject *object)
+{
+  GtkListBoxPrivate *priv = BOX_PRIV (object);
+
+  if (priv->placeholder)
+    {
+      gtk_widget_unparent (priv->placeholder);
+      priv->placeholder = NULL;
+    }
+
+  G_OBJECT_CLASS (gtk_list_box_parent_class)->dispose (object);
+}
+
 static void
 gtk_list_box_class_init (GtkListBoxClass *klass)
 {
@@ -421,6 +435,7 @@ gtk_list_box_class_init (GtkListBoxClass *klass)
   object_class->get_property = gtk_list_box_get_property;
   object_class->set_property = gtk_list_box_set_property;
   object_class->finalize = gtk_list_box_finalize;
+  object_class->dispose = gtk_list_box_dispose;
   widget_class->enter_notify_event = gtk_list_box_enter_notify_event;
   widget_class->leave_notify_event = gtk_list_box_leave_notify_event;
   widget_class->motion_notify_event = gtk_list_box_motion_notify_event;