From a39e519bed033ab3fd7585a791ff820cbcd19558 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 17 Oct 2020 13:11:58 -0400 Subject: [PATCH] inspector: Clear overlays on unroot In dispose(), we can't access the root anymore, since we're already unrooted. Fixes: #3265 --- gtk/inspector/visual.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c index ac18bd9720..fd082112e2 100644 --- a/gtk/inspector/visual.c +++ b/gtk/inspector/visual.c @@ -1069,13 +1069,11 @@ gtk_inspector_visual_constructed (GObject *object) } static void -gtk_inspector_visual_dispose (GObject *object) +gtk_inspector_visual_unroot (GtkWidget *widget) { - GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object); + GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (widget); GtkInspectorWindow *iw = GTK_INSPECTOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (vis))); - g_clear_pointer (&vis->swin, gtk_widget_unparent); - if (vis->layout_overlay) { gtk_inspector_window_remove_overlay (iw, vis->layout_overlay); @@ -1097,6 +1095,16 @@ gtk_inspector_visual_dispose (GObject *object) vis->focus_overlay = NULL; } + GTK_WIDGET_CLASS (gtk_inspector_visual_parent_class)->unroot (widget); +} + +static void +gtk_inspector_visual_dispose (GObject *object) +{ + GtkInspectorVisual *vis = GTK_INSPECTOR_VISUAL (object); + + g_clear_pointer (&vis->swin, gtk_widget_unparent); + G_OBJECT_CLASS (gtk_inspector_visual_parent_class)->dispose (object); } @@ -1109,6 +1117,8 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass) object_class->constructed = gtk_inspector_visual_constructed; object_class->dispose = gtk_inspector_visual_dispose; + widget_class->unroot = gtk_inspector_visual_unroot; + gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/visual.ui"); gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, swin); gtk_widget_class_bind_template_child (widget_class, GtkInspectorVisual, box);