[gtksourceview/wip/chergert/vim] clear parent child pointer upon pop()



commit c6879d049ee4b8866cca2894aa4ce210b80425f1
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 27 15:30:15 2021 -0700

    clear parent child pointer upon pop()

 gtksourceview/vim/gtk-source-vim-state.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index 59b6ad22..ffed08f1 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -426,13 +426,15 @@ void
 gtk_source_vim_state_pop (GtkSourceVimState *self)
 {
        GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
-       g_autoptr(GtkSourceVimState) parent = NULL;
+       GtkSourceVimStatePrivate *parent_priv;
+       GtkSourceVimState *parent;
 
        g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
        g_return_if_fail (priv->child == NULL);
        g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (priv->parent));
 
        parent = g_object_ref (priv->parent);
+       parent_priv = gtk_source_vim_state_get_instance_private (parent);
 
        if (GTK_SOURCE_VIM_STATE_GET_CLASS (self)->leave)
        {
@@ -444,6 +446,16 @@ gtk_source_vim_state_pop (GtkSourceVimState *self)
                GTK_SOURCE_VIM_STATE_GET_CLASS (parent)->resume (parent, self);
        }
 
+       /* Clear the parent's child pointer, since we are no longer the
+        * active event delivery child. However, the parent can still keep
+        * a reference around elsewhere if they like for replaying things.
+        */
+       if (parent_priv->child == self)
+       {
+               parent_priv->child = NULL;
+       }
+
+       g_clear_object (&parent);
        g_object_unref (self);
 }
 


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