fontchooser: Fix objects-finalize test
authorMatthias Clasen <mclasen@redhat.com>
Tue, 14 Jan 2020 20:25:27 +0000 (15:25 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 14 Jan 2020 20:25:27 +0000 (15:25 -0500)
The treeview is evil and keeps reference cycles in the
form of various tree row references. That gets cleaned up
if you explicitly gtk_widget_destroy the treeview. But since
07f2024bfca22331121, the scrolled window no longer destroys
its child, exposing this issue as a reference leak in
the objects-finalize test.

The font chooser widget is affected here because it calls
gtk_tree_view_scroll_to_path from init(), which creates one
of those reference cycles. Work around this in the font
chooser by unsetting the tree view model in dispose, which
clears up this cycle.

gtk/gtkfontchooserwidget.c

index a0a94494210a3da014c4acc6fca1e68b3c6bcef9..686a8de13ac007c1eb85037d2d6cde2f4bf66edc 100644 (file)
@@ -716,6 +716,7 @@ gtk_font_chooser_widget_dispose (GObject *object)
   GtkFontChooserWidget *self = GTK_FONT_CHOOSER_WIDGET (object);
   GtkFontChooserWidgetPrivate *priv = gtk_font_chooser_widget_get_instance_private (self);
 
+  gtk_tree_view_set_model (GTK_TREE_VIEW (priv->family_face_list), NULL);
   g_clear_pointer (&priv->stack, gtk_widget_unparent);
 
   G_OBJECT_CLASS (gtk_font_chooser_widget_parent_class)->dispose (object);