From: Ryan Lortie Date: Sat, 26 Oct 2013 22:49:58 +0000 (-0400) Subject: Clean up GSettingsSchema logic X-Git-Tag: 2.39.1~144 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e462eda3d5c86349bd5daa7db687e582001390d7;p=platform%2Fupstream%2Fglib.git Clean up GSettingsSchema logic The way we created the global schema list predates g_settings_schema_source_new_from_directory() and therefore doesn't use it. Update it to use that function, removing some code. https://bugzilla.gnome.org/show_bug.cgi?id=668232 --- diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c index fe43b89..26b6d48 100644 --- a/gio/gsettingsschema.c +++ b/gio/gsettingsschema.c @@ -176,6 +176,7 @@ G_DEFINE_BOXED_TYPE (GSettingsSchema, g_settings_schema, g_settings_schema_ref, struct _GSettingsSchemaSource { GSettingsSchemaSource *parent; + gchar *directory; GvdbTable *table; gint ref_count; @@ -183,20 +184,6 @@ struct _GSettingsSchemaSource static GSettingsSchemaSource *schema_sources; -static void -prepend_schema_table (GvdbTable *table) -{ - GSettingsSchemaSource *source; - - /* we steal the reference from 'schema_sources' for our ->parent */ - source = g_slice_new (GSettingsSchemaSource); - source->parent = schema_sources; - source->table = table; - source->ref_count = 1; - - schema_sources = source; -} - /** * g_settings_schema_source_ref: * @source: a #GSettingsSchemaSource @@ -234,6 +221,7 @@ g_settings_schema_source_unref (GSettingsSchemaSource *source) if (source->parent) g_settings_schema_source_unref (source->parent); gvdb_table_unref (source->table); + g_free (source->directory); g_slice_free (GSettingsSchemaSource, source); } @@ -297,6 +285,7 @@ g_settings_schema_source_new_from_directory (const gchar *directory, return NULL; source = g_slice_new (GSettingsSchemaSource); + source->directory = g_strdup (directory); source->parent = parent ? g_settings_schema_source_ref (parent) : NULL; source->table = table; source->ref_count = 1; @@ -305,6 +294,18 @@ g_settings_schema_source_new_from_directory (const gchar *directory, } static void +try_prepend_dir (const gchar *directory) +{ + GSettingsSchemaSource *source; + + source = g_settings_schema_source_new_from_directory (directory, schema_sources, TRUE, NULL); + + /* If we successfully created it then prepend it to the global list */ + if (source != NULL) + schema_sources = source; +} + +static void initialise_schema_sources (void) { static gsize initialised; @@ -324,31 +325,15 @@ initialise_schema_sources (void) while (i--) { - gchar *filename; - GvdbTable *table; - - filename = g_build_filename (dirs[i], "glib-2.0", "schemas", "gschemas.compiled", NULL); - table = gvdb_table_new (filename, TRUE, NULL); + gchar *dirname; - if (table != NULL) - prepend_schema_table (table); - - g_free (filename); + dirname = g_build_filename (dirs[i], "glib-2.0", "schemas", NULL); + try_prepend_dir (dirname); + g_free (dirname); } if ((path = g_getenv ("GSETTINGS_SCHEMA_DIR")) != NULL) - { - gchar *filename; - GvdbTable *table; - - filename = g_build_filename (path, "gschemas.compiled", NULL); - table = gvdb_table_new (filename, TRUE, NULL); - - if (table != NULL) - prepend_schema_table (table); - - g_free (filename); - } + try_prepend_dir (path); g_once_init_leave (&initialised, TRUE); }