Hello Gtkmm developers and users,
I am currently using Gtkmm to develop an embedded Linux UI.
So far I have been able to find all relevant information in the Gnome and Gtkmm documentation -> good work!
However, now I stumbled upon a problem I cannot figure out myself. I am trying to read a DBus property using get_cached_property(). The property variant has the form a{q(qsb)} meaning a dictionary/map with uint16 keys and tuple values. I have tried following
to read the variant:
Glib::Variant< std::map<guint16, Glib::VariantContainerBase> > driver_map; m_userman->get_cached_property(driver_map, "DriverList"); auto data = driver_map.get(); Throws following error: In file included from /usr/include/glibmm-2.4/glibmm/containerhandle_shared.h:25:0, from /usr/include/glibmm-2.4/glibmm/object.h:34, from /usr/include/giomm-2.4/giomm/dbusconnection.h:29, from dbushandler.h:3, from dbushandler.cpp:1: /usr/include/glibmm-2.4/glibmm/variant.h: In instantiation of ‘std::pair<_T1, _T2> Glib::Variant<std::pair<_T1, _T2> >::get() const [with K = short int; V = Glib::VariantContainerBase]’: /usr/include/glibmm-2.4/glibmm/variant.h:1722:5: required from ‘std::map<K, V> Glib::Variant<std::map<K, V> >::get() const [with K = short int; V = Glib::VariantContainerBase]’ dbushandler.cpp:88:36: required from here /usr/include/glibmm-2.4/glibmm/variant.h:1549:48: error: ‘class Glib::Variant<Glib::VariantContainerBase>’ has no member named ‘get’ std::pair<K, V> result(key.get(), value.get()); ^ /usr/include/glibmm-2.4/glibmm/variant.h: In instantiation of ‘static const Glib::VariantType& Glib::Variant<std::pair<_T1, _T2> >::variant_type() [with K = short int; V = Glib::VariantContainerBase]’: /usr/include/glibmm-2.4/glibmm/variant.h:1643:71: required from ‘static const Glib::VariantType& Glib::Variant<std::map<K, V> >::variant_type() [with K = short int; V = Glib::VariantContainerBase]’ /usr/include/glibmm-2.4/glibmm/variant.h:1731:53: required from ‘Glib::VariantIter Glib::Variant<std::map<K, V> >::get_iter() const [with K = short int; V = Glib::VariantContainerBase]’ /usr/include/glibmm-2.4/glibmm/variant.h:1717:30: required from ‘std::map<K, V> Glib::Variant<std::map<K, V> >::get() const [with K = short int; V = Glib::VariantContainerBase]’ dbushandler.cpp:88:36: required from here /usr/include/glibmm-2.4/glibmm/variant.h:1520:29: error: ‘variant_type’ is not a member of ‘Glib::Variant<Glib::VariantContainerBase>’ Variant<V>::variant_type().gobj()));
I also tried this second approach: Glib::Variant< std::map<guint16, Glib::Variant<std::vector<Glib::VariantBase> > > > driver_map; m_userman->get_cached_property(driver_map, "DriverList"); auto data = driver_map.get(); Which throws following error at runtime: (launcher:10778): GLib-CRITICAL **: the GVariant format string 'a{qv}' has a type of 'a{qv}' but the given value has a type of 'a{q(qsb)}'
(launcher:10778): GLib-CRITICAL **: g_variant_get: assertion 'valid_format_string (format_string, TRUE, value)' failed
(launcher:10778): GLib-CRITICAL **: g_variant_iter_next_value: assertion 'is_valid_iter (iter)' failed
Does anyone have an idea how to decode this type of variant in Glibmm?
Best regards, Alexander |