diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c index df26e3b..8229407 100644 --- a/dbus/dbus-gobject.c +++ b/dbus/dbus-gobject.c @@ -1224,8 +1224,8 @@ invoke_object_method (GObject *object, g_value_init (&gvalue, _dbus_gtype_from_signature_iter (&argsigiter, FALSE)); if (G_VALUE_TYPE (&gvalue) != G_TYPE_VALUE) { - if (!_dbus_gvalue_take (&gvalue, - &(g_array_index (out_param_values, GTypeCValue, out_param_pos)))) + if (!_dbus_gvalue_take_cvalue (&gvalue, + &(g_array_index (out_param_values, GTypeCValue, out_param_pos)))) g_assert_not_reached (); out_param_pos++; } @@ -1237,8 +1237,8 @@ invoke_object_method (GObject *object, if (!_dbus_gvalue_marshal (&iter, &gvalue)) goto nomem; - /* Here we actually free the allocated value; we - * took ownership of it with _dbus_gvalue_take, unless + /* Here we actually free the allocated value; we took + * ownership of it with _dbus_gvalue_take_cvalue, unless * an annotation has specified this value as constant. */ if (!constval) diff --git a/dbus/dbus-gproxy.c b/dbus/dbus-gproxy.c index 3d5a0c5..2583744 100644 --- a/dbus/dbus-gproxy.c +++ b/dbus/dbus-gproxy.c @@ -2223,6 +2223,7 @@ dbus_g_proxy_end_call_internal (DBusGProxy *proxy, g_assert (reply != NULL); dbus_error_init (&derror); + G_VA_COPY (args_unwind, args); switch (dbus_message_get_type (reply)) { @@ -2276,7 +2277,7 @@ dbus_g_proxy_end_call_internal (DBusGProxy *proxy, goto out; /* Anything that can be demarshaled must be storable */ - if (!_dbus_gvalue_store (&gvalue, (gpointer*) return_storage)) + if (!_dbus_gvalue_get (&gvalue, (gpointer*) return_storage)) g_assert_not_reached (); /* Ownership of the value passes to the client, don't unset */ } @@ -2319,18 +2320,24 @@ dbus_g_proxy_end_call_internal (DBusGProxy *proxy, ret = TRUE; out: - va_end (args); if (ret == FALSE) { int i; + + valtype = first_arg_type; for (i = 0; i < n_retvals_processed; i++) { - gpointer retval; + GValue gvalue = { 0, }; + gpointer storage; + + g_value_init (&gvalue, valtype); - retval = va_arg (args_unwind, gpointer); + storage = va_arg (args_unwind, gpointer); + if (storage && _dbus_gvalue_take (&gvalue, storage)) + g_value_unset(&gvalue); - g_free (retval); + valtype = va_arg (args_unwind, GType); } } va_end (args_unwind); diff --git a/dbus/dbus-gvalue-utils.c b/dbus/dbus-gvalue-utils.c index ca9e173..e4ccb9c 100644 --- a/dbus/dbus-gvalue-utils.c +++ b/dbus/dbus-gvalue-utils.c @@ -72,8 +72,8 @@ _dbus_g_type_fixed_get_size (GType type) } gboolean -_dbus_gvalue_store (GValue *value, - gpointer storage) +_dbus_gvalue_get (GValue *value, + gpointer storage) { /* FIXME - can we use the GValue lcopy_value method * to do this in a cleaner way? @@ -125,8 +125,8 @@ _dbus_gvalue_store (GValue *value, } gboolean -_dbus_gvalue_set_from_pointer (GValue *value, - gconstpointer storage) +_dbus_gvalue_set (GValue *value, + gconstpointer storage) { /* FIXME - is there a better way to do this? */ switch (g_type_fundamental (G_VALUE_TYPE (value))) @@ -176,8 +176,48 @@ _dbus_gvalue_set_from_pointer (GValue *value, } gboolean +_dbus_gvalue_dup (GValue *value, + gpointer storage) +{ + switch (g_type_fundamental (G_VALUE_TYPE (value))) + { + case G_TYPE_STRING: + *((gchar **) storage) = (gchar*) g_value_dup_string (value); + return TRUE; + case G_TYPE_OBJECT: + *((gpointer *) storage) = g_value_dup_object (value); + return TRUE; + case G_TYPE_BOXED: + *((gpointer *) storage) = g_value_dup_boxed (value); + return TRUE; + default: + return _dbus_gvalue_get (value, storage); + } +} + +gboolean _dbus_gvalue_take (GValue *value, - GTypeCValue *cvalue) + gpointer storage) +{ + switch (g_type_fundamental (G_VALUE_TYPE (value))) + { + case G_TYPE_STRING: + g_value_take_string (value, *((gchar **) storage)); + return TRUE; + case G_TYPE_OBJECT: + g_value_take_object (value, *((gpointer *) storage)); + return TRUE; + case G_TYPE_BOXED: + g_value_take_boxed (value, *((gpointer *) storage)); + return TRUE; + default: + return _dbus_gvalue_set (value, storage); + } +} + +gboolean +_dbus_gvalue_take_cvalue (GValue *value, + GTypeCValue *cvalue) { GType g_type; GTypeValueTable *value_table; diff --git a/dbus/dbus-gvalue-utils.h b/dbus/dbus-gvalue-utils.h index cba3b61..49fb91a 100644 --- a/dbus/dbus-gvalue-utils.h +++ b/dbus/dbus-gvalue-utils.h @@ -34,9 +34,6 @@ void _dbus_g_type_specialized_builtins_init (void); gboolean _dbus_g_type_is_fixed (GType gtype); guint _dbus_g_type_fixed_get_size (GType gtype); -gboolean _dbus_gvalue_set_from_pointer (GValue *value, - gconstpointer storage); - typedef void (*DBusGHashValueForeachFunc) (GValue * key, GValue *val, gpointer data); void _dbus_g_hash_table_value_foreach (GHashTable *table, @@ -58,10 +55,19 @@ GHashFunc _dbus_g_hash_func_from_gtype (GType gtype); GEqualFunc _dbus_g_hash_equal_from_gtype (GType gtype); GDestroyNotify _dbus_g_hash_free_from_gtype (GType gtype); -gboolean _dbus_gvalue_store (GValue *value, +gboolean _dbus_gvalue_get (GValue *value, + gpointer storage); + +gboolean _dbus_gvalue_set (GValue *value, + gconstpointer storage); + +gboolean _dbus_gvalue_dup (GValue *value, gpointer storage); gboolean _dbus_gvalue_take (GValue *value, + gpointer storage); + +gboolean _dbus_gvalue_take_cvalue (GValue *value, GTypeCValue *cvalue); gboolean _dbus_gtype_can_signal_error (GType gtype);