[sysprof/wip/gtk4-port: 125/132] libsysprof-ui: clean up and remove child widgets




commit 85ad29dd1342fa7fa64e5b7706d95f8e0ca882a6
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 1 15:34:28 2021 -0700

    libsysprof-ui: clean up and remove child widgets

 src/libsysprof-ui/sysprof-details-page.c         | 15 +++++++++++++++
 src/libsysprof-ui/sysprof-failed-state-view.c    | 15 +++++++++++++++
 src/libsysprof-ui/sysprof-recording-state-view.c |  4 ++++
 src/libsysprof-ui/sysprof-visualizers-frame.c    | 10 +++++++---
 4 files changed, 41 insertions(+), 3 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-details-page.c b/src/libsysprof-ui/sysprof-details-page.c
index ad63f090..ac0178b3 100644
--- a/src/libsysprof-ui/sysprof-details-page.c
+++ b/src/libsysprof-ui/sysprof-details-page.c
@@ -77,10 +77,25 @@ _g_date_time_new_from_iso8601 (const gchar *str,
 }
 #endif
 
+static void
+sysprof_details_page_dispose (GObject *object)
+{
+  SysprofDetailsPage *self = (SysprofDetailsPage *)object;
+  GtkWidget *child;
+
+  while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
+    gtk_widget_unparent (child);
+
+  G_OBJECT_CLASS (sysprof_details_page_parent_class)->dispose (object);
+}
+
 static void
 sysprof_details_page_class_init (SysprofDetailsPageClass *klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->dispose = sysprof_details_page_dispose;
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/sysprof/ui/sysprof-details-page.ui");
   gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
diff --git a/src/libsysprof-ui/sysprof-failed-state-view.c b/src/libsysprof-ui/sysprof-failed-state-view.c
index b2c5e9a7..6ca02e7d 100644
--- a/src/libsysprof-ui/sysprof-failed-state-view.c
+++ b/src/libsysprof-ui/sysprof-failed-state-view.c
@@ -30,11 +30,26 @@ sysprof_failed_state_view_new (void)
   return g_object_new (SYSPROF_TYPE_FAILED_STATE_VIEW, NULL);
 }
 
+static void
+sysprof_failed_state_view_dispose (GObject *object)
+{
+  SysprofFailedStateView *self = (SysprofFailedStateView *)object;
+  GtkWidget *child;
+
+  while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
+    gtk_widget_unparent (child);
+
+  G_OBJECT_CLASS (sysprof_failed_state_view_parent_class)->dispose (object);
+}
+
 static void
 sysprof_failed_state_view_class_init (SysprofFailedStateViewClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
+  object_class->dispose = sysprof_failed_state_view_dispose;
+
   gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
   gtk_widget_class_set_template_from_resource (widget_class,
                                                "/org/gnome/sysprof/ui/sysprof-failed-state-view.ui");
diff --git a/src/libsysprof-ui/sysprof-recording-state-view.c 
b/src/libsysprof-ui/sysprof-recording-state-view.c
index b37978bb..ea025a4b 100644
--- a/src/libsysprof-ui/sysprof-recording-state-view.c
+++ b/src/libsysprof-ui/sysprof-recording-state-view.c
@@ -83,6 +83,10 @@ sysprof_recording_state_view_dispose (GObject *object)
 {
   SysprofRecordingStateView *self = (SysprofRecordingStateView *)object;
   SysprofRecordingStateViewPrivate *priv = sysprof_recording_state_view_get_instance_private (self);
+  GtkWidget *child;
+
+  while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
+    gtk_widget_unparent (child);
 
   if (priv->profiler != NULL)
     {
diff --git a/src/libsysprof-ui/sysprof-visualizers-frame.c b/src/libsysprof-ui/sysprof-visualizers-frame.c
index 5e9740d3..67803cbe 100644
--- a/src/libsysprof-ui/sysprof-visualizers-frame.c
+++ b/src/libsysprof-ui/sysprof-visualizers-frame.c
@@ -373,13 +373,17 @@ sysprof_visualizers_frame_size_allocate (GtkWidget *widget,
 }
 
 static void
-sysprof_visualizers_frame_finalize (GObject *object)
+sysprof_visualizers_frame_dispose (GObject *object)
 {
   SysprofVisualizersFrame *self = (SysprofVisualizersFrame *)object;
+  GtkWidget *child;
+
+  while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
+    gtk_widget_unparent (child);
 
   g_clear_object (&self->selection);
 
-  G_OBJECT_CLASS (sysprof_visualizers_frame_parent_class)->finalize (object);
+  G_OBJECT_CLASS (sysprof_visualizers_frame_parent_class)->dispose (object);
 }
 
 static void
@@ -411,7 +415,7 @@ sysprof_visualizers_frame_class_init (SysprofVisualizersFrameClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class->finalize = sysprof_visualizers_frame_finalize;
+  object_class->dispose = sysprof_visualizers_frame_dispose;
   object_class->get_property = sysprof_visualizers_frame_get_property;
 
   widget_class->size_allocate = sysprof_visualizers_frame_size_allocate;


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