inspector: Dispose tree data properly

Another place where we were leaking children.
This commit is contained in:
Matthias Clasen 2020-07-17 22:54:19 -04:00
parent 9ffd7d1970
commit af30a7fe06

View File

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