GNOME Bugzilla – Bug 635187
Wrong type of GVariant received in an action configured in a GApplication
Last modified: 2010-11-29 13:06:28 UTC
Created attachment 174777 [details] Tester to simulate the issue I create a GApplication and configure an action which must receive a string GVariant with g_simple_action_new ("dummy", G_VARIANT_TYPE_STRING); Then, I will activate the action if the application is not the original instance, passing a string variant as that's the one expected by the action: if (g_application_get_is_remote (application)) { g_action_group_activate_action (G_ACTION_GROUP (application), "dummy", g_variant_new_string ("Calling...")); } But when variant is received in the original instance, before invoking the action it checks the type and fails: (gapplication-test:13269): GLib-GIO-CRITICAL **: g_simple_action_activate: assertion `simple->priv->parameter_type == NULL ? parameter == NULL : (parameter != NULL && g_variant_is_of_type (parameter, simple->priv->parameter_type))' failed When running under gdb, I see that the received GVariant is a G_VARIANT_TYPE_VARIANT instead of G_VARIANT_TYPE_STRING: Breakpoint 1, g_simple_action_activate (action=0x8054420, parameter=0x8061d48) at gsimpleaction.c:157 157 GSimpleAction *simple = G_SIMPLE_ACTION (action); (gdb) p (gchar *)(g_variant_get_type (parameter)) $1 = (gchar *) 0xb7e66ac8 "v"
Created attachment 174780 [details] [review] Patch for the issue The GVariant passed in g_action_group_activate_action () is always boxed when the GApplication is acting as a proxy, before the dbus call is done, in g_application_impl_activate_action(), gio/gapplicationimpl-dbus.c: if (parameter) parameter = g_variant_new_variant (parameter); So when the action is received via dbus, in g_application_impl_actions_method_call(), we need to always unbox the received GVariant before passing it to g_action_group_activate_action()