File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
include/dbus-glue/bindings
source/dbus-glue/bindings Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -535,6 +535,15 @@ namespace DBusGlue
535535 }
536536 };
537537
538+ template <>
539+ struct message ::read_proxy <message_variant, void >
540+ {
541+ static int read (message& msg, message_variant& object)
542+ {
543+ return msg.read_variant (object);
544+ }
545+ };
546+
538547 // -----------------------------------------------------------------------------------------------------------------
539548 // append_proxy
540549 // -----------------------------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -51,17 +51,24 @@ namespace DBusGlue
5151
5252 auto * handle = msg.msg ;
5353
54- r = sd_bus_message_enter_container (handle, SD_BUS_TYPE_VARIANT, msg.type ().contained .data ());
55- if (r < 0 )
56- throw std::runtime_error (" could not enter variant" );
54+ bool isTrueVariant = (msg.type ().type == ' v' );
55+ if (isTrueVariant)
56+ {
57+ r = sd_bus_message_enter_container (handle, SD_BUS_TYPE_VARIANT, msg.type ().contained .data ());
58+ if (r < 0 )
59+ throw std::runtime_error (" could not enter variant" );
60+ }
5761
5862 message_.reset (new message (msg.bus (), 2 ));
5963 msg.copy_into (*message_.get (), false );
6064 message_->seal ();
6165
62- r = sd_bus_message_exit_container (handle);
63- if (r < 0 )
64- throw std::runtime_error (" could copy exit variant" );
66+ if (isTrueVariant)
67+ {
68+ r = sd_bus_message_exit_container (handle);
69+ if (r < 0 )
70+ throw std::runtime_error (" could copy exit variant" );
71+ }
6572
6673 return r;
6774 }
You can’t perform that action at this time.
0 commit comments