[gnome-builder] libide/tweaks: generate dynamic buildable ids during copy
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: generate dynamic buildable ids during copy
- Date: Wed, 3 Aug 2022 19:27:15 +0000 (UTC)
commit 7bdd5ff6f15e4f077d9f45876226b4069aa46f6b
Author: Christian Hergert <chergert redhat com>
Date: Wed Aug 3 12:09:32 2022 -0700
libide/tweaks: generate dynamic buildable ids during copy
We don't want to end up with the same object-id, as these could be coming
from an IdeTweaksFactory.
src/libide/tweaks/ide-tweaks-item.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-item.c b/src/libide/tweaks/ide-tweaks-item.c
index 08f862e99..2026a4e63 100644
--- a/src/libide/tweaks/ide-tweaks-item.c
+++ b/src/libide/tweaks/ide-tweaks-item.c
@@ -35,6 +35,7 @@ typedef struct
char *id;
char **keywords;
char *sort_key;
+ guint id_sequence;
} IdeTweaksItemPrivate;
enum {
@@ -65,9 +66,11 @@ clear_value (gpointer data)
static IdeTweaksItem *
ide_tweaks_item_real_copy (IdeTweaksItem *self)
{
+ IdeTweaksItemPrivate *priv = ide_tweaks_item_get_instance_private (self);
g_autoptr(GPtrArray) names = NULL;
g_autoptr(GArray) values = NULL;
g_autofree GParamSpec **pspecs = NULL;
+ g_autofree char *id = NULL;
GObject *copy;
GType item_type;
guint n_pspecs;
@@ -99,10 +102,15 @@ ide_tweaks_item_real_copy (IdeTweaksItem *self)
copy = g_object_new_with_properties (item_type,
names->len,
(const char **)names->pdata,
- (const GValue *)values->data);
+ (const GValue *)(gpointer)values->data);
+
+ /* Generate dynamic id for this item based on our id */
+ if (priv->id != NULL)
+ id = g_strdup_printf ("%s__copy__%u", priv->id, ++priv->id_sequence);
+ else
+ id = g_strdup_printf ("%p_copy_%u", self, ++priv->id_sequence);
- ide_tweaks_item_set_buildable_id (GTK_BUILDABLE (copy),
- ide_tweaks_item_get_id (self));
+ ide_tweaks_item_set_buildable_id (GTK_BUILDABLE (copy), id);
for (IdeTweaksItem *child = ide_tweaks_item_get_first_child (self);
child != NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]