[gtksourceview/wip/chergert/vim] clear child during dispose first



commit 0b8d75e8c848771c2d18a444cde1fb6f9b5222f1
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 29 15:49:53 2021 -0700

    clear child during dispose first

 gtksourceview/vim/gtk-source-vim-state.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index 9039d697..9d7798dc 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -145,6 +145,15 @@ gtk_source_vim_state_dispose (GObject *object)
        GtkSourceVimState *self = (GtkSourceVimState *)object;
        GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
 
+       /* Cleanup children first so they can access the ancestors during
+        * destruction if necessary.
+        */
+       if (priv->child != NULL)
+       {
+               GtkSourceVimState *child = g_steal_pointer (&priv->child);
+               gtk_source_vim_state_set_parent (child, NULL);
+       }
+
        /* This is extra protection to ensure that we don't have a dangling
         * child pointer in the parent state. Generally, if
         * gtk_source_vim_state_pop() is called properly this cannot happen


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