[gnome-builder] libide/io: avoid signal emission during cached model desctruction



commit c8e847fbf5b301c75eff079ef406e77ec6969100
Author: Christian Hergert <chergert redhat com>
Date:   Tue Aug 2 15:51:56 2022 -0700

    libide/io: avoid signal emission during cached model desctruction
    
    We don't want to risk re-entrancy cycles during dispose, so avoid any
    emission once dispose is called.
    
    Fixes #1745

 src/libide/io/ide-cached-list-model.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/io/ide-cached-list-model.c b/src/libide/io/ide-cached-list-model.c
index fe17d3cd2..c711ac025 100644
--- a/src/libide/io/ide-cached-list-model.c
+++ b/src/libide/io/ide-cached-list-model.c
@@ -30,6 +30,8 @@ struct _IdeCachedListModel
   GSequence  *items;
   GListModel *model;
   gulong      items_changed_handler;
+
+  guint       in_dispose : 1;
 };
 
 enum {
@@ -109,6 +111,8 @@ ide_cached_list_model_dispose (GObject *object)
 {
   IdeCachedListModel *self = (IdeCachedListModel *)object;
 
+  self->in_dispose = TRUE;
+
   ide_cached_list_model_set_model (self, NULL);
 
   g_assert (self->model == NULL);
@@ -270,8 +274,11 @@ ide_cached_list_model_set_model (IdeCachedListModel *self,
 
   g_set_object (&self->model, model);
 
-  if (removed || added)
-    g_list_model_items_changed (G_LIST_MODEL (self), 0, removed, added);
+  if (!self->in_dispose)
+    {
+      if (removed || added)
+        g_list_model_items_changed (G_LIST_MODEL (self), 0, removed, added);
+    }
 
   g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
 }


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