[gnome-builder] libide/tweaks: don't pass project-id if schema is non-relocatable
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/tweaks: don't pass project-id if schema is non-relocatable
- Date: Sat, 27 Aug 2022 08:27:26 +0000 (UTC)
commit 06d610f3e0092882a6fd3a938ad43652ebbe965a
Author: Christian Hergert <chergert redhat com>
Date: Sat Aug 27 01:26:07 2022 -0700
libide/tweaks: don't pass project-id if schema is non-relocatable
src/libide/tweaks/ide-tweaks-setting.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
---
diff --git a/src/libide/tweaks/ide-tweaks-setting.c b/src/libide/tweaks/ide-tweaks-setting.c
index e95fd45c5..61530a5c0 100644
--- a/src/libide/tweaks/ide-tweaks-setting.c
+++ b/src/libide/tweaks/ide-tweaks-setting.c
@@ -66,6 +66,25 @@ ide_tweaks_setting_settings_changed_cb (IdeTweaksSetting *self,
ide_tweaks_binding_changed (IDE_TWEAKS_BINDING (self));
}
+static gboolean
+schema_is_relocatable (const char *schema_id)
+{
+ GSettingsSchemaSource *source;
+ g_autoptr(GSettingsSchema) schema = NULL;
+
+ g_assert (schema_id != NULL);
+
+ source = g_settings_schema_source_get_default ();
+
+ if (!(schema = g_settings_schema_source_lookup (source, schema_id, TRUE)))
+ {
+ g_critical ("No such schema: %s", schema_id);
+ return FALSE;
+ }
+
+ return g_settings_schema_get_path (schema) == NULL;
+}
+
static GSettings *
ide_tweaks_setting_acquire (IdeTweaksSetting *self,
const char **key,
@@ -89,11 +108,15 @@ ide_tweaks_setting_acquire (IdeTweaksSetting *self,
g_autofree char *path = NULL;
g_autofree char *signal_name = NULL;
g_autoptr(GVariant) value = NULL;
- IdeTweaksItem *root;
const char *project_id = NULL;
- if ((root = ide_tweaks_item_get_root (IDE_TWEAKS_ITEM (self))) && IDE_IS_TWEAKS (root))
- project_id = ide_tweaks_get_project_id (IDE_TWEAKS (root));
+ if (schema_is_relocatable (self->schema_id))
+ {
+ IdeTweaksItem *root;
+
+ if ((root = ide_tweaks_item_get_root (IDE_TWEAKS_ITEM (self))) && IDE_IS_TWEAKS (root))
+ project_id = ide_tweaks_get_project_id (IDE_TWEAKS (root));
+ }
if (!(path = ide_settings_resolve_schema_path (self->schema_id, project_id, self->path_suffix)))
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]