GNOME Bugzilla – Bug 747508
Glib::Variant does not correctly handle all GVariants with object paths
Last modified: 2015-04-13 17:04:38 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
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.
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'.
https://git.gnome.org/browse/glibmm/commit/?id=6641ac99f95e02c7ef9e4259f6b6b8af1dcbb3f4