Re: gconf_engine_get_for_address behavior



Mark,

Thanks for the fix. 

Hemanth

>>> Mark McLoughlin <mark skynet ie> 4/23/2004 4:59:31 PM >>>
Hi,

On Fri, 2004-04-23 at 11:22, Hemanth Yamijala wrote:
> Mark,
> 
> Sorry for not being complete. Here's the complete output:
> 
> =======================================
> Acquired engine handle using gconf_engine_get_for_address: asas
> Could not get engine using gconf_engine_get_local: asas
> Message: Couldn't resolve address for configuration source:
>  Bad address `asas' 
> =======================================

	Right - "asas" is an invalid address - you must use
xml:readwrite:/path/to/source

> However, my problem is that, in both the cases,
> gconf_engine_get_for_address
> is not returning an error. I wanted to know if this behavior is
> expected.

	No, I've fixed that now on gnome-2-6 and HEAD with the patch
below.

Thanks,
Mark.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gconf/ChangeLog,v
retrieving revision 1.515
diff -u -p -r1.515 ChangeLog
--- ChangeLog	21 Apr 2004 17:46:04 -0000	1.515
+++ ChangeLog	23 Apr 2004 11:25:09 -0000
@@ -0,0 +1,5 @@
+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.
+
Index: gconf/gconf-sources.c
===================================================================
RCS file: /cvs/gnome/gconf/gconf/gconf-sources.c,v
retrieving revision 1.48
diff -u -p -r1.48 gconf-sources.c
--- gconf/gconf-sources.c	31 Mar 2004 09:09:14 -0000	1.48
+++ gconf/gconf-sources.c	23 Apr 2004 11:25:10 -0000
@@ -335,37 +335,59 @@ gconf_source_remove_listener (GConfSourc
 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;
+      GError *last_error = NULL;
+
+      while (addresses != NULL)
+	{
+	  GConfSource* source;
+
+	  if (last_error)
+	    {
+	      g_error_free (last_error);
+	      last_error = NULL;
+	    }
       
-      source = gconf_resolve_address((const gchar*)addresses->data,
&error);
+	  source = gconf_resolve_address ((const gchar*)addresses->data,
&last_error);
 
-      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);
-        }
+	  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;





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]