[gtk/inspector-fixes: 2/4] inspector: Clean up on finalize



commit c31185b419078cc4e63d6a6e43059cdfc96ce99c
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Apr 6 15:46:14 2019 +0000

    inspector: Clean up on finalize
    
    Just a matter of cleanliness.

 gtk/inspector/visual.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index dcdec7d42f..8f369139c4 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -918,6 +918,22 @@ gtk_inspector_visual_constructed (GObject *object)
    g_signal_connect (vis->priv->gl_box, "keynav-failed", G_CALLBACK (keynav_failed), vis);
 }
 
+static void
+gtk_inspector_visual_finalize (GObject *object)
+{
+  GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object);
+  GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (vis)));
+
+  if (vis->priv->layout_overlay)
+    gtk_inspector_window_remove_overlay (iw, vis->priv->layout_overlay);
+  if (vis->priv->updates_overlay)
+    gtk_inspector_window_remove_overlay (iw, vis->priv->updates_overlay);
+  if (vis->priv->fps_overlay)
+    gtk_inspector_window_remove_overlay (iw, vis->priv->fps_overlay);
+
+  G_OBJECT_CLASS (gtk_inspector_visual_parent_class)->finalize (object);
+}
+
 static void
 gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
 {
@@ -925,6 +941,7 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->constructed = gtk_inspector_visual_constructed;
+  object_class->finalize = gtk_inspector_visual_finalize;
 
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/visual.ui");
   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, direction_combo);


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