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 747508 - Glib::Variant does not correctly handle all GVariants with object paths
Glib::Variant does not correctly handle all GVariants with object paths
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
2.44.x
Other All
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2015-04-08 14:47 UTC by Kjell Ahlstedt
Modified: 2015-04-13 17:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch: Glib::Variant: Improved handling of object paths and signatures (21.06 KB, patch)
2015-04-08 14:55 UTC, Kjell Ahlstedt
none Details | Review

Description Kjell Ahlstedt 2015-04-08 14:47:56 UTC
A Glib::Variant<Glib::ustring> can contain a GVariant of type
VARIANT_TYPE_STRING (s), VARIANT_TYPE_OBJECT_PATH (o) or
VARIANT_TYPE_SIGNATURE (g).

A Glib::Variant<std::string> can contain a GVariant of type
VARIANT_TYPE_BYTESTRING (ay), VARIANT_TYPE_STRING (s),
VARIANT_TYPE_OBJECT_PATH (o) or VARIANT_TYPE_SIGNATURE (g).

That's fine, but it does work like that for composite types, such as
Variant<std::map<Glib::ustring, double> > or
Variant<std::map<Glib::ustring, std::vector<std::string> > >.
Then Glib::ustring must correspond to VARIANT_TYPE_STRING and std::string
to VARIANT_TYPE_BYTESTRING. That's inconsistent.

See https://mail.gnome.org/archives/gtkmm-list/2015-March/msg00028.html
Comment 1 Kjell Ahlstedt 2015-04-08 14:55:42 UTC
Created attachment 301143 [details] [review]
patch: Glib::Variant: Improved handling of object paths and signatures

This patch fixes the bug, I hope, making the Variant classes handle object
paths and DBus type signatures correctly also in complicated types.

It was fairly straight-forward to fix cast_dynamic(), but fixing all the
get(), get_child() and get_iter() methods required lots of small changes.
I've added a test case to glibmm/tests/glibmm_variant. It would be fine
it someone else, with easy access to complicated GVariants, could
make more tests.
Comment 2 Andrejs Hanins 2015-04-13 08:44:13 UTC
I have tested the patch (applied to Glibmm 2.44.0) and confirm that it is now possible to parse the signature a{oa{sa{sv}}} (D-Bus ObjectManager response) by using the following type:

Glib::Variant<std::map<Glib::ustring,
        std::map<Glib::ustring, std::map<Glib::ustring, Glib::VariantBase>>>>

Important thing here is that standard string type Glib::ustring is used in place of D-Bus object patch 'o'.