summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@pobox.com>2001-12-18 17:50:59 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-12-18 17:50:59 +0000
commitd984be29c8a8192e9bba07d692efad6ffc722f2d (patch)
treed1701d70948ed75392242ec3818980475c6d76f3
parent89c7daf33e9fdcb1838bffc6652f095e2475cd93 (diff)
downloadgconf-d984be29c8a8192e9bba07d692efad6ffc722f2d.tar.gz
Backport from HEAD
2001-12-17 Havoc Pennington <hp@pobox.com> Backport from HEAD * backends/xml-dir.c (dir_get_value): always get schema name, not just if value is unset * gconf/gconf-sources.c (gconf_sources_query_value): don't look for a default value for the schema. Useless and adds a bit of inefficiency. * gconf/gconf-sources.c (gconf_sources_query_value): Fix this so Gergo's bug doesn't happen; hope no other semantic gets broken.
-rw-r--r--ChangeLog14
-rw-r--r--backends/xml-dir.c9
-rw-r--r--gconf/gconf-sources.c130
3 files changed, 99 insertions, 54 deletions
diff --git a/ChangeLog b/ChangeLog
index 900d16d9..2b428d30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,20 @@
Backport from HEAD
+ * backends/xml-dir.c (dir_get_value): always get schema name, not
+ just if value is unset
+
+ * gconf/gconf-sources.c (gconf_sources_query_value): don't look
+ for a default value for the schema. Useless and adds a bit of
+ inefficiency.
+
+ * gconf/gconf-sources.c (gconf_sources_query_value): Fix this so
+ Gergo's bug doesn't happen; hope no other semantic gets broken.
+
+2001-12-17 Havoc Pennington <hp@pobox.com>
+
+ Backport from HEAD
+
* gconf/gconf-listeners.c: reference count the listeners, make a
copy of listener lists and ref all listeners prior to doing the
notifies, to minimize reentrancy screwups.
diff --git a/backends/xml-dir.c b/backends/xml-dir.c
index 46db0a63..f5e15bd2 100644
--- a/backends/xml-dir.c
+++ b/backends/xml-dir.c
@@ -487,12 +487,9 @@ dir_get_value (Dir* d,
val = entry_get_value (e, locales, err);
- /* Fill schema name if value is NULL because we might be
- interested in the default value of the key in that case. */
- if (schema_name &&
- val == NULL &&
- entry_get_schema_name(e))
- *schema_name = g_strdup(entry_get_schema_name(e));
+ /* Get schema name if requested */
+ if (schema_name && entry_get_schema_name (e))
+ *schema_name = g_strdup (entry_get_schema_name (e));
/* return copy of the value */
if (val != NULL)
diff --git a/gconf/gconf-sources.c b/gconf/gconf-sources.c
index 183ad80d..728a964b 100644
--- a/gconf/gconf-sources.c
+++ b/gconf/gconf-sources.c
@@ -391,12 +391,13 @@ gconf_sources_query_value (GConfSources* sources,
GError** err)
{
GList* tmp;
- gchar* schema_name = NULL;
- GError* error = NULL;
+ gchar* schema_name;
+ GError* error;
+ GConfValue* val;
- g_return_val_if_fail(sources != NULL, NULL);
- g_return_val_if_fail(key != NULL, NULL);
- g_return_val_if_fail((err == NULL) || (*err == NULL), NULL);
+ g_return_val_if_fail (sources != NULL, NULL);
+ g_return_val_if_fail (key != NULL, NULL);
+ g_return_val_if_fail ((err == NULL) || (*err == NULL), NULL);
/* A value is writable if it is unset and a writable source exists,
* or if it's set and the setting is within or after a writable source.
@@ -415,84 +416,117 @@ gconf_sources_query_value (GConfSources* sources,
if (schema_namep)
*schema_namep = NULL;
+
+ val = NULL;
+ schema_name = NULL;
+ error = NULL;
tmp = sources->sources;
while (tmp != NULL)
{
- GConfValue* val;
- GConfSource* source;
+ GConfSource* source;
gchar** schema_name_retloc;
- /* we only want the first schema name we find */
- if (use_schema_default)
- schema_name_retloc = schema_name ? NULL : &schema_name;
- else
+ schema_name_retloc = &schema_name;
+ if (schema_name != NULL || /* already have the schema name */
+ (schema_namep == NULL && !use_schema_default)) /* don't need to get the schema name */
schema_name_retloc = NULL;
source = tmp->data;
- if (value_is_writable &&
- source_is_writable (source, key, NULL)) /* ignore errors */
- *value_is_writable = TRUE;
-
- val = gconf_source_query_value(source, key, locales,
- schema_name_retloc, &error);
-
- if (error != NULL)
+ if (val == NULL)
{
- /* Right thing to do? Don't know. */
- g_assert(val == NULL);
+ /* A key is writable if the source containing its value or
+ * an earlier source is writable
+ */
+ if (value_is_writable &&
+ source_is_writable (source, key, NULL)) /* ignore errors */
+ *value_is_writable = TRUE;
+
+ val = gconf_source_query_value (source, key, locales,
+ schema_name_retloc, &error);
+ }
+ else if (schema_name_retloc != NULL)
+ {
+ GConfMetaInfo *mi;
+
+ mi = gconf_source_query_metainfo (source, key, &error);
+
+ if (mi)
+ {
+ *schema_name_retloc = mi->schema;
+ mi->schema = NULL;
+ gconf_meta_info_free (mi);
+ }
+ }
+
+ if (error != NULL)
+ {
if (err)
*err = error;
else
- g_error_free(error);
+ g_error_free (error);
error = NULL;
+ if (val)
+ gconf_value_free (val);
+
+ if (schema_name)
+ g_free (schema_name);
+
return NULL;
}
-
- if (val == NULL)
+
+ /* schema_name_retloc == NULL means we aren't still looking for schema name,
+ * tmp->next == NULL means we aren't going to get a schema name
+ */
+ if (val != NULL && (schema_name_retloc == NULL || schema_name != NULL || tmp->next == NULL))
{
- ; /* keep going, try more sources */
+ if (schema_namep)
+ *schema_namep = schema_name;
+ else
+ g_free (schema_name);
+
+ return val;
}
else
{
- g_free (schema_name);
- schema_name = NULL;
- return val;
+ ; /* Keep looking for either val or schema name */
}
-
- tmp = g_list_next(tmp);
+
+ tmp = g_list_next (tmp);
}
- g_return_val_if_fail(error == NULL, NULL);
+ g_return_val_if_fail (error == NULL, NULL);
+ g_return_val_if_fail (val == NULL, NULL);
/* If we got here, there was no value; we try to look up the
- schema for this key if we have one, and use the default
- value.
- */
+ * schema for this key if we have one, and use the default
+ * value.
+ */
if (schema_name != NULL)
{
- GConfValue* val;
-
- /* Note that if the value isn't found, then it's always the default
- value - even if there is no default value, NULL is the default.
- This makes things more sane (I think) because is_default
- basically means "was set by user" - however we also want to say
- that if use_schema_default is FALSE then value_is_default will be FALSE
- so we put this inside the schema_name != NULL conditional
+ /* Note that if the value isn't found, then it's always the
+ * default value - even if there is no default value, NULL is
+ * the default. This makes things more sane (I think) because
+ * is_default basically means "was set by user" - however we
+ * also want to say that if use_schema_default is FALSE then
+ * value_is_default will be FALSE so we put this inside the
+ * schema_name != NULL conditional
*/
if (value_is_default)
*value_is_default = TRUE;
-
- /* We do look for a schema describing the schema, just for funnies */
- val = gconf_sources_query_value(sources, schema_name, locales,
- TRUE, NULL, NULL, NULL, &error);
+ if (use_schema_default)
+ {
+ val = gconf_sources_query_value (sources, schema_name, locales,
+ FALSE, NULL, NULL, NULL, &error);
+ }
+
if (error != NULL)
{
if (err)
@@ -506,8 +540,8 @@ gconf_sources_query_value (GConfSources* sources,
else if (val != NULL &&
val->type != GCONF_VALUE_SCHEMA)
{
- gconf_set_error(err, GCONF_ERROR_FAILED,
- _("Schema `%s' specified for `%s' stores a non-schema value"), schema_name, key);
+ gconf_set_error (err, GCONF_ERROR_FAILED,
+ _("Schema `%s' specified for `%s' stores a non-schema value"), schema_name, key);
if (schema_namep)
*schema_namep = schema_name;