summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark McLoughlin <mark@skynet.ie>2004-04-23 11:27:31 +0000
committerMark McLoughlin <markmc@src.gnome.org>2004-04-23 11:27:31 +0000
commitb29ea27af335f6c8bc0197c9d1ca3cfd2a4344f4 (patch)
treedddc53c399c2898d4b713799d22e33c83debbdd8
parentac1a3be9fb328e8024f7aa9740e22ef7e2f84743 (diff)
downloadgconf-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--ChangeLog5
-rw-r--r--gconf/gconf-sources.c68
2 files changed, 50 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index e3d0400a..ad2f8296 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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;