cpw.gillux.detachablepurple: 1258821d: Fixed the calling of D-Bus methods that ...

gillux at soc.pidgin.im gillux at soc.pidgin.im
Fri May 25 15:46:45 EDT 2012


----------------------------------------------------------------------
Revision: 1258821dd0c17cfa7c68aae4b3d46bc19d1e6e83
Parent:   42a3b4be168a51f122a91d663050807a722afc38
Author:   gillux at soc.pidgin.im
Date:     05/25/12 15:32:20
Branch:   im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/1258821dd0c17cfa7c68aae4b3d46bc19d1e6e83

Changelog: 

Fixed the calling of D-Bus methods that doesn't return values.

Changes against parent 42a3b4be168a51f122a91d663050807a722afc38

  patched  libpurple/pobject.c

-------------- next part --------------
============================================================
--- libpurple/pobject.c	a5d73b962339760940a4c3f846ea270b4997e1a9
+++ libpurple/pobject.c	5803f51d95b391bf219f3822643f177229fb665c
@@ -762,6 +762,7 @@ purple_object_generic_dbus_method_handle
 	GValue ret_val = {0, };
 	GClosure *closure;
 	guint i, num_params;
+	GDBusMethodInfo *method_info;
 
 	/* Get the binded function back. */
 	closure = purple_object_get_dbus_closure(PURPLE_OBJECT_GET_CLASS(object),
@@ -776,27 +777,34 @@ purple_object_generic_dbus_method_handle
 	purple_gvariant_to_gvalue_closure_args(object, params,
 	                                       &paramv, &num_params);
 
+	/* Check if this method has a return value. */
+	method_info = g_dbus_method_invocation_get_method_info(invoc);
+	if (!method_info->out_args) {
+		g_closure_invoke(closure, NULL, num_params, paramv, NULL);
+		g_dbus_method_invocation_return_value(invoc, NULL);
+	} else {
 /* We don't want to force such a recent version, so keep a shitty workaround. */
 #if GLIB_CHECK_VERSION(2, 32, 1)
-	g_value_init(&ret_val, G_TYPE_VARIANT);
+		g_value_init(&ret_val, G_TYPE_VARIANT);
 
-	/* Execute the callback. */
-	g_closure_invoke(closure, &ret_val, num_params, paramv, NULL);
-	g_dbus_method_invocation_return_value(invoc,
+		/* Execute the callback. */
+		g_closure_invoke(closure, &ret_val, num_params, paramv, NULL);
+		g_dbus_method_invocation_return_value(invoc,
 	                                      g_value_get_variant(&ret_val));
 #else
-	g_value_init(&ret_val, G_TYPE_POINTER);
+		g_value_init(&ret_val, G_TYPE_POINTER);
 
-	/* Execute the callback. */
-	g_closure_invoke(closure, &ret_val, num_params, paramv, NULL);
-	g_dbus_method_invocation_return_value(invoc,
+		/* Execute the callback. */
+		g_closure_invoke(closure, &ret_val, num_params, paramv, NULL);
+		g_dbus_method_invocation_return_value(invoc,
 	                                (GVariant*)g_value_get_pointer(&ret_val));
 #endif
+		g_value_unset(&ret_val);
+	}
 
 	for (i = 0; i < num_params; i++)
 		g_value_unset (&paramv[i]);
 	g_free (paramv);
-	g_value_unset(&ret_val);
 }
 
 GVariant *


More information about the Commits mailing list