mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
Merge branch 'bugfix/gsettings-schema-has-key' into 'main'
Fix g_settings_schema_has_key() to work with extended schemas Closes #3548 See merge request GNOME/glib!4420
This commit is contained in:
commit
f5941d3284
@ -1055,7 +1055,16 @@ gboolean
|
||||
g_settings_schema_has_key (GSettingsSchema *schema,
|
||||
const gchar *key)
|
||||
{
|
||||
return gvdb_table_has_value (schema->table, key);
|
||||
GSettingsSchema *s;
|
||||
|
||||
if (gvdb_table_has_value (schema->table, key))
|
||||
return TRUE;
|
||||
|
||||
for (s = schema; s; s = s->extends)
|
||||
if (gvdb_table_has_value (s->table, key))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3239,7 +3239,7 @@ test_extended_schema (void)
|
||||
GSettings *settings;
|
||||
gchar **keys;
|
||||
|
||||
settings = g_settings_new_with_path ("org.gtk.test.extends.extended", "/test/extendes/");
|
||||
settings = g_settings_new_with_path ("org.gtk.test.extends.extended", "/test/extends/");
|
||||
g_object_get (settings, "settings-schema", &schema, NULL);
|
||||
keys = g_settings_schema_list_keys (schema);
|
||||
g_assert_true (strv_set_equal ((const gchar * const *) keys, "int32", "string", "another-int32", NULL));
|
||||
@ -3248,6 +3248,21 @@ test_extended_schema (void)
|
||||
g_settings_schema_unref (schema);
|
||||
}
|
||||
|
||||
static void
|
||||
test_extended_schema_has_key (void)
|
||||
{
|
||||
GSettingsSchema *schema;
|
||||
GSettings *settings;
|
||||
|
||||
settings = g_settings_new_with_path ("org.gtk.test.extends.extended", "/test/extends/");
|
||||
g_object_get (settings, "settings-schema", &schema, NULL);
|
||||
g_assert_true (g_settings_schema_has_key (schema, "int32"));
|
||||
g_assert_true (g_settings_schema_has_key (schema, "string"));
|
||||
g_assert_true (g_settings_schema_has_key (schema, "another-int32"));
|
||||
g_object_unref (settings);
|
||||
g_settings_schema_unref (schema);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@ -3429,6 +3444,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/gsettings/memory-backend", test_memory_backend);
|
||||
g_test_add_func ("/gsettings/read-descriptions", test_read_descriptions);
|
||||
g_test_add_func ("/gsettings/test-extended-schema", test_extended_schema);
|
||||
g_test_add_func ("/gsettings/test-extended-schema-has-key", test_extended_schema_has_key);
|
||||
g_test_add_func ("/gsettings/default-value", test_default_value);
|
||||
g_test_add_func ("/gsettings/per-desktop", test_per_desktop);
|
||||
g_test_add_func ("/gsettings/per-desktop/subprocess", test_per_desktop_subprocess);
|
||||
|
Loading…
Reference in New Issue
Block a user