How to set a variant property #466
-
Hey all, I have a question on how to use the variant type in combination with method arguments or properties. I have a property that can take in a variety of data types. Because of this I have given it the variant type. This works great for reading from it, but I cannot get setting the value to work. sdbus seems to collapse the variants together. When running the following code i get the error: sdbus::Variant newVariant{sdbus::Variant{double{3}}};
spdlog::info("Setting value: {} of type {}", newVariant, newVariant.peekValueType());
param.Value(newVariant); I used the interface generator with the following description of the parameter: <property name="Value" type="v" access="readwrite">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
</property> How can I write to this property? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi, currently there is no way to embed a variant into another variant. This is a shortcoming on the part of sdbus-c++, so I'm converting this to an issue. |
Beta Was this translation helpful? Give feedback.
-
@robojan Once #467 is merged, you can take the latest master (but I'll also create a new tag - v2.1.0). Then, since you're saying you're using bindings generated from the XML, just re-generate your bindings and setting the property of type variant shall work OK then. |
Beta Was this translation helpful? Give feedback.
-
New release https://github.com/Kistler-Group/sdbus-cpp/releases/tag/v2.1.0 has been published with the fixes for your issue. |
Beta Was this translation helpful? Give feedback.
New release https://github.com/Kistler-Group/sdbus-cpp/releases/tag/v2.1.0 has been published with the fixes for your issue.