[Xfce4-commits] <xfconf:master> fix detection of channel/property not found error when setting props

Brian J. Tarricone brian at tarricone.org
Sun Aug 23 10:24:01 CEST 2009


Updating branch refs/heads/master
         to 0aa4faca0929d45902e878fd859aba37c35d04e7 (commit)
       from 86cfde6cddef120622d91af606ecaf417186a678 (commit)

commit 0aa4faca0929d45902e878fd859aba37c35d04e7
Author: Brian J. Tarricone <brian at tarricone.org>
Date:   Sun Aug 23 01:20:39 2009 -0700

    fix detection of channel/property not found error when setting props
    
    dbus-glib's GError registration/mapping is crap.  instead of doing
    something actually useful and mapping the error returned by dbus
    (e.g. "org.xfce.Xfconf.Error.PropertyNotFound") back into the
    correct GError domain (XFCONF_ERROR) and GError code
    (XFCONF_ERROR_PROPERTY_NOT_FOUND), it instead uselessly uses
    DBUS_GERROR and DBUS_GERROR_REMOTE_EXCEPTION, and then tacks the
    raw error string onto the end of GError::message, "hiding" it
    with a NUL byte.  useless.

 xfconf/xfconf-cache.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/xfconf/xfconf-cache.c b/xfconf/xfconf-cache.c
index 674bdef..049436c 100644
--- a/xfconf/xfconf-cache.c
+++ b/xfconf/xfconf-cache.c
@@ -711,9 +711,24 @@ xfconf_cache_set(XfconfCache *cache,
         GError *tmp_error = NULL;
 
         if(!xfconf_cache_lookup_locked(cache, property, &tmp_val, &tmp_error)) {
-            if(G_UNLIKELY(tmp_error->domain != XFCONF_ERROR
-                          || (tmp_error->code != XFCONF_ERROR_CHANNEL_NOT_FOUND
-                              && tmp_error->code != XFCONF_ERROR_PROPERTY_NOT_FOUND)))
+            /* this is just another example of dbus-glib's brain-deadedness.
+             * instead of remapping the remote error back into the local
+             * domain and code, it uses DBUS_GERROR as the domain,
+             * DBUS_GERROR_REMOTE_EXCEPTION as the code, and then "hides"
+             * the full string ("org.xfce.Xfconf.Error.Whatever") in
+             * GError::message after a NUL byte.  so stupid. */
+            const gchar *dbus_error_name = NULL;
+
+            if(G_LIKELY(tmp_error->domain == DBUS_GERROR
+                        && tmp_error->code == DBUS_GERROR_REMOTE_EXCEPTION))
+            {
+                dbus_error_name = dbus_g_error_get_name(tmp_error);
+            }
+
+            if(G_UNLIKELY(!dbus_error_name
+                          || strncmp(dbus_error_name, "org.xfce.Xfconf.Error.", 22)
+                          || (strcmp(dbus_error_name+22, "PropertyNotFound")
+                              && strcmp(dbus_error_name+22, "ChannelNotFound"))))
             {
                 /* this is bad... */
                 g_propagate_error(error, tmp_error);



More information about the Xfce4-commits mailing list