[gtk/inspector-fixes] inspector: Fix some lifecycle issues




commit e68b365fa19486c32cbe25a4073b8251557d015c
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 4 07:08:25 2022 -0400

    inspector: Fix some lifecycle issues
    
    The template use in the inspector was not properly
    disposing all widgets. gtk_widget_dispose_template
    will only unparent widgets that have been named
    as template children, so we need to make the toplevel
    elements in the ui file named children, or manually
    dispose them. This commit does the former.

 gtk/inspector/actions.c    | 2 ++
 gtk/inspector/actions.ui   | 2 +-
 gtk/inspector/list-data.c  | 4 ++++
 gtk/inspector/list-data.ui | 4 ++--
 gtk/inspector/logs.c       | 2 ++
 gtk/inspector/logs.ui      | 2 +-
 gtk/inspector/tree-data.c  | 4 ++++
 gtk/inspector/tree-data.ui | 4 ++--
 8 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/gtk/inspector/actions.c b/gtk/inspector/actions.c
index 24afc47856..99ec6fffed 100644
--- a/gtk/inspector/actions.c
+++ b/gtk/inspector/actions.c
@@ -40,6 +40,7 @@ struct _GtkInspectorActions
 {
   GtkWidget parent;
 
+  GtkWidget *swin;
   GtkWidget *list;
   GtkWidget *button;
 
@@ -446,6 +447,7 @@ gtk_inspector_actions_class_init (GtkInspectorActionsClass *klass)
                            GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/actions.ui");
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorActions, swin);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorActions, list);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorActions, name);
   gtk_widget_class_bind_template_callback (widget_class, setup_name_cb);
diff --git a/gtk/inspector/actions.ui b/gtk/inspector/actions.ui
index 6b5982555b..a48b0ba638 100644
--- a/gtk/inspector/actions.ui
+++ b/gtk/inspector/actions.ui
@@ -5,7 +5,7 @@
       <class name="view"/>
     </style>
     <child>
-      <object class="GtkScrolledWindow">
+      <object class="GtkScrolledWindow" id="swin">
         <property name="hexpand">1</property>
         <property name="vexpand">1</property>
         <property name="hscrollbar-policy">never</property>
diff --git a/gtk/inspector/list-data.c b/gtk/inspector/list-data.c
index c56defef95..149b4af113 100644
--- a/gtk/inspector/list-data.c
+++ b/gtk/inspector/list-data.c
@@ -36,6 +36,8 @@ struct _GtkInspectorListData
 {
   GtkWidget parent_instance;
 
+  GtkWidget *box;
+  GtkWidget *swin;
   GListModel *object;
   GtkColumnView *view;
   GtkWidget *items_label;
@@ -205,6 +207,8 @@ gtk_inspector_list_data_class_init (GtkInspectorListDataClass *klass)
   object_class->dispose = dispose;
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/list-data.ui");
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorListData, box);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorListData, swin);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorListData, view);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorListData, items_label);
 
diff --git a/gtk/inspector/list-data.ui b/gtk/inspector/list-data.ui
index d3124ed548..2403d36581 100644
--- a/gtk/inspector/list-data.ui
+++ b/gtk/inspector/list-data.ui
@@ -1,7 +1,7 @@
 <interface domain="gtk40">
   <template class="GtkInspectorListData" parent="GtkWidget">
     <child>
-      <object class="GtkBox">
+      <object class="GtkBox" id="box">
         <property name="spacing">6</property>
         <property name="margin-start">6</property>
         <property name="margin-end">6</property>
@@ -16,7 +16,7 @@
       </object>
     </child>
     <child>
-      <object class="GtkScrolledWindow">
+      <object class="GtkScrolledWindow" id="swin">
         <property name="hexpand">1</property>
         <property name="vexpand">1</property>
         <property name="vscrollbar-policy">always</property>
diff --git a/gtk/inspector/logs.c b/gtk/inspector/logs.c
index 7872838145..d0e6fc9b3d 100644
--- a/gtk/inspector/logs.c
+++ b/gtk/inspector/logs.c
@@ -47,6 +47,7 @@ struct _GtkInspectorLogs
 {
   GtkWidget parent;
 
+  GtkWidget *box;
   GtkWidget *events;
   GtkWidget *misc;
   GtkWidget *dnd;
@@ -185,6 +186,7 @@ gtk_inspector_logs_class_init (GtkInspectorLogsClass *klass)
   object_class->dispose = dispose;
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/logs.ui");
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, box);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, events);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, misc);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorLogs, dnd);
diff --git a/gtk/inspector/logs.ui b/gtk/inspector/logs.ui
index fc457c8a9e..89e01dc42f 100644
--- a/gtk/inspector/logs.ui
+++ b/gtk/inspector/logs.ui
@@ -1,7 +1,7 @@
 <interface domain="gtk40">
   <template class="GtkInspectorLogs" parent="GtkWidget">
     <child>
-      <object class="GtkBox">
+      <object class="GtkBox" id="box">
         <property name="margin-start">20</property>
         <property name="margin-end">20</property>
         <property name="margin-top">20</property>
diff --git a/gtk/inspector/tree-data.c b/gtk/inspector/tree-data.c
index b0e23c2933..42cec69a84 100644
--- a/gtk/inspector/tree-data.c
+++ b/gtk/inspector/tree-data.c
@@ -35,6 +35,8 @@ struct _GtkInspectorTreeData
 {
   GtkWidget parent_instance;
 
+  GtkWidget *box;
+  GtkWidget *swin;
   GtkTreeModel *object;
   GtkTreeModel *types;
   GtkTreeView *view;
@@ -190,6 +192,8 @@ gtk_inspector_tree_data_class_init (GtkInspectorTreeDataClass *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, box);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorTreeData, swin);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorTreeData, view);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorTreeData, object_title);
   gtk_widget_class_bind_template_callback (widget_class, toggle_show);
diff --git a/gtk/inspector/tree-data.ui b/gtk/inspector/tree-data.ui
index d06c228136..9e0d98148b 100644
--- a/gtk/inspector/tree-data.ui
+++ b/gtk/inspector/tree-data.ui
@@ -1,7 +1,7 @@
 <interface domain="gtk40">
   <template class="GtkInspectorTreeData" parent="GtkWidget">
     <child>
-      <object class="GtkBox">
+      <object class="GtkBox" id="box">
         <style>
           <class name="toolbar"/>
         </style>
@@ -21,7 +21,7 @@
       </object>
     </child>
     <child>
-      <object class="GtkScrolledWindow">
+      <object class="GtkScrolledWindow" id="swin">
         <property name="hexpand">1</property>
         <property name="vexpand">1</property>
         <property name="vscrollbar-policy">always</property>


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