diff options
author | Mark McLoughlin <mark@skynet.ie> | 2004-04-23 11:27:31 +0000 |
---|---|---|
committer | Mark McLoughlin <markmc@src.gnome.org> | 2004-04-23 11:27:31 +0000 |
commit | b29ea27af335f6c8bc0197c9d1ca3cfd2a4344f4 (patch) | |
tree | dddc53c399c2898d4b713799d22e33c83debbdd8 | |
parent | ac1a3be9fb328e8024f7aa9740e22ef7e2f84743 (diff) | |
download | gconf-b29ea27af335f6c8bc0197c9d1ca3cfd2a4344f4.tar.gz |
return NULL and the last error if we failed to resolve any of the
2004-04-23 Mark McLoughlin <mark@skynet.ie>
* gconf/gconf-sources.c: (gconf_sources_new_from_addresses): return
NULL and the last error if we failed to resolve any of the addresses.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | gconf/gconf-sources.c | 68 |
2 files changed, 50 insertions, 23 deletions
@@ -1,3 +1,8 @@ +2004-04-23 Mark McLoughlin <mark@skynet.ie> + + * gconf/gconf-sources.c: (gconf_sources_new_from_addresses): return + NULL and the last error if we failed to resolve any of the addresses. + 2004-04-19 Mark McLoughlin <mark@skynet.ie> * configure.in: post-release bump to 2.6.2 diff --git a/gconf/gconf-sources.c b/gconf/gconf-sources.c index 0962c4bd..5e788ab1 100644 --- a/gconf/gconf-sources.c +++ b/gconf/gconf-sources.c @@ -295,37 +295,59 @@ gconf_source_sync_all (GConfSource* source, GError** err) GConfSources* gconf_sources_new_from_addresses(GSList * addresses, GError** err) { - GConfSources* sources; + GConfSources *sources; + GList *sources_list; g_return_val_if_fail( (err == NULL) || (*err == NULL), NULL); - - sources = g_new0(GConfSources, 1); - while (addresses != NULL) + sources_list = NULL; + if (addresses != NULL) { - GConfSource* source; - GError* error = NULL; - - source = gconf_resolve_address((const gchar*)addresses->data, &error); + GError *last_error = NULL; - if (source != NULL) - { - sources->sources = g_list_prepend(sources->sources, source); - g_return_val_if_fail(error == NULL, NULL); - } - else - { - g_assert(error != NULL); - gconf_log(GCL_WARNING, _("Failed to load source \"%s\": %s"), - (const gchar*)addresses->data, error->message); - - g_error_free(error); - } + while (addresses != NULL) + { + GConfSource* source; + + if (last_error) + { + g_error_free (last_error); + last_error = NULL; + } + + source = gconf_resolve_address ((const gchar*)addresses->data, &last_error); + + if (source != NULL) + { + sources_list = g_list_prepend(sources_list, source); + g_return_val_if_fail(last_error == NULL, NULL); + } + else + { + g_assert(last_error != NULL); + gconf_log(GCL_WARNING, _("Failed to load source \"%s\": %s"), + (const gchar*)addresses->data, last_error->message); + } - addresses = g_slist_next(addresses); + addresses = g_slist_next(addresses); + } + + if (sources_list == NULL) + { + g_assert (last_error != NULL); + g_propagate_error (err, last_error); + return NULL; + } + + if (last_error) + { + g_error_free(last_error); + last_error = NULL; + } } - sources->sources = g_list_reverse(sources->sources); + sources = g_new0 (GConfSources, 1); + sources->sources = g_list_reverse (sources_list); { GList *tmp; |