[gjs] dbus: Don't return [ undefined ] when parsing an empty list of values



commit 21e25e643acce5f6641fa06b862a370ca0cbf9e2
Author: Johan Bilien <jobi litl com>
Date:   Fri Sep 17 23:04:33 2010 +0000

    dbus: Don't return [ undefined ] when parsing an empty list of values
    
    instead return []
    
    This is a problem for asynchronously implemented methods with an empty
    in-signature. Without the fix they are called with
    methodAsync(undefined, dbusCallback) instead of the expected
    methodAsync(dbusCallback);
    
    https://bugzilla.gnome.org/show_bug.cgi?id=629965

 modules/dbus-values.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/modules/dbus-values.c b/modules/dbus-values.c
index 1dae132..6d77767 100644
--- a/modules/dbus-values.c
+++ b/modules/dbus-values.c
@@ -314,15 +314,17 @@ gjs_js_values_from_dbus(JSContext          *context,
 
     array = gjs_rooted_array_new();
 
-    do {
-        if (!gjs_js_one_value_from_dbus(context, iter, &value)) {
-            gjs_rooted_array_free(context, array, TRUE);
-            JS_RemoveRoot(context, &value);
-            return JS_FALSE; /* error message already set */
-        }
+    if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) {
+        do {
+            if (!gjs_js_one_value_from_dbus(context, iter, &value)) {
+                gjs_rooted_array_free(context, array, TRUE);
+                JS_RemoveRoot(context, &value);
+                return JS_FALSE; /* error message already set */
+            }
 
-        gjs_rooted_array_append(context, array, value);
-    } while (dbus_message_iter_next(iter));
+            gjs_rooted_array_append(context, array, value);
+        } while (dbus_message_iter_next(iter));
+    }
 
     *array_p = array;
 



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