[gtk/fix-action-muxer-parent-chain: 2/2] action muxer: Be safe against reinsertion



commit 42d44c4416156750981c1a0237369cfc2aa088c5
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jun 23 22:55:19 2019 +0000

    action muxer: Be safe against reinsertion
    
    Be prepared for the eventuality that somebody
    might reinsert the same action group without
    holding any extra references on it.
    
    This was observed as causing crashes in
    gnome-builder.

 gtk/gtkactionmuxer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkactionmuxer.c b/gtk/gtkactionmuxer.c
index ee97cd294f..d6c3d26161 100644
--- a/gtk/gtkactionmuxer.c
+++ b/gtk/gtkactionmuxer.c
@@ -683,12 +683,14 @@ gtk_action_muxer_insert (GtkActionMuxer *muxer,
   Group *group;
   gint i;
 
+  g_object_ref (action_group);
+
   /* TODO: diff instead of ripout and replace */
   gtk_action_muxer_remove (muxer, prefix);
 
   group = g_slice_new (Group);
   group->muxer = muxer;
-  group->group = g_object_ref (action_group);
+  group->group = action_group;
   group->prefix = g_strdup (prefix);
 
   g_hash_table_insert (muxer->groups, group->prefix, group);


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