[gtk/matthiasc/for-master: 4/8] inspector: Dispose tree data properly



commit af30a7fe06b94cec6564f3684bebd4b6775de1bf
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jul 17 22:54:19 2020 -0400

    inspector: Dispose tree data properly
    
    Another place where we were leaking children.

 gtk/inspector/tree-data.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
---
diff --git a/gtk/inspector/tree-data.c b/gtk/inspector/tree-data.c
index 4c0b3b8394..fdf77a2cfd 100644
--- a/gtk/inspector/tree-data.c
+++ b/gtk/inspector/tree-data.c
@@ -171,11 +171,26 @@ toggle_show (GtkToggleButton      *button,
     show_types (sl);
 }
 
+static void
+dispose (GObject *object)
+{
+  GtkInspectorTreeData *sl = GTK_INSPECTOR_TREE_DATA (object);
+  GtkWidget *child;
+
+  while ((child = gtk_widget_get_first_child (GTK_WIDGET (sl))))
+    gtk_widget_unparent (child);
+
+  G_OBJECT_CLASS (gtk_inspector_tree_data_parent_class)->dispose (object);
+}
+
 static void
 gtk_inspector_tree_data_class_init (GtkInspectorTreeDataClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->dispose = dispose;
+
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/tree-data.ui");
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorTreeData, view);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorTreeData, object_title);


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