[gnome-builder] libide/tweaks: keep branch nodes around from visiting
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: keep branch nodes around from visiting
- Date: Wed, 17 Aug 2022 05:08:30 +0000 (UTC)
commit 3063acc1ae3d6e22fa6e0670b6a0cabc00d77fa0
Author: Christian Hergert <chergert redhat com>
Date: Tue Aug 16 22:02:39 2022 -0700
libide/tweaks: keep branch nodes around from visiting
We might have an intermediate branch around that requires stashing or we
loose our copy-on-clone chain to the root. Just hold a reference for each
of the items we inflate.
src/libide/tweaks/ide-tweaks-model.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
---
diff --git a/src/libide/tweaks/ide-tweaks-model.c b/src/libide/tweaks/ide-tweaks-model.c
index 1107e7e8b..5a50afb20 100644
--- a/src/libide/tweaks/ide-tweaks-model.c
+++ b/src/libide/tweaks/ide-tweaks-model.c
@@ -31,6 +31,7 @@ struct _IdeTweaksModel
GObject parent_instance;
IdeTweaksItem *item;
GPtrArray *items;
+ GPtrArray *branches;
IdeTweaksItemVisitor visitor;
gpointer visitor_data;
GDestroyNotify visitor_data_destroy;
@@ -101,6 +102,20 @@ ide_tweaks_model_populate_cb (IdeTweaksItem *item,
{
case IDE_TWEAKS_ITEM_VISIT_ACCEPT_AND_CONTINUE:
g_ptr_array_add (self->items, g_object_ref (item));
+
+ /* We might need to keep the parents around up to our factory so
+ * that they are not disposed after visiting.
+ */
+ for (IdeTweaksItem *iter = ide_tweaks_item_get_parent (item);
+ iter != NULL && iter != self->item;
+ iter = ide_tweaks_item_get_parent (iter))
+ {
+ guint pos;
+
+ if (!g_ptr_array_find (self->branches, iter, &pos))
+ g_ptr_array_add (self->branches, g_object_ref (iter));
+ }
+
return IDE_TWEAKS_ITEM_VISIT_CONTINUE;
case IDE_TWEAKS_ITEM_VISIT_RECURSE:
@@ -153,6 +168,7 @@ ide_tweaks_model_dispose (GObject *object)
IdeTweaksModel *self = (IdeTweaksModel *)object;
g_clear_object (&self->item);
+ g_clear_pointer (&self->branches, g_ptr_array_unref);
if (self->visitor_data_destroy)
{
@@ -202,6 +218,7 @@ ide_tweaks_model_class_init (IdeTweaksModelClass *klass)
static void
ide_tweaks_model_init (IdeTweaksModel *self)
{
+ self->branches = g_ptr_array_new_with_free_func (g_object_unref);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]