After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 635187 - Wrong type of GVariant received in an action configured in a GApplication
Wrong type of GVariant received in an action configured in a GApplication
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gapplication
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 635162
 
 
Reported: 2010-11-18 16:17 UTC by Aleksander Morgado
Modified: 2010-11-29 13:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Tester to simulate the issue (2.29 KB, text/x-c)
2010-11-18 16:17 UTC, Aleksander Morgado
  Details
Patch for the issue (1.46 KB, patch)
2010-11-18 17:05 UTC, Aleksander Morgado
none Details | Review

Description Aleksander Morgado 2010-11-18 16:17:00 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"
Comment 1 Aleksander Morgado 2010-11-18 17:05:28 UTC
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()