From 33985fb2020884955ed44db825ace7cf0ec32bbc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 27 Dec 2009 10:55:33 -0200 Subject: Fix D-Bus marshalling of booleans in optimised code. C++ booleans are 1 byte in size, but D-Bus booleans (dbus_bool_t) are 4 bytes. That means a boolean with a zero in the LSB byte but non-zero garbage in the high bytes is a valid "false" in C++, but libdbus-1 will turn that to true when sending. Task-number: QTBUG-7041 Reviewed-By: Trust Me BT: yes --- src/dbus/qdbusmarshaller.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index f381b27..76821c8 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -378,7 +378,6 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) switch (*signature) { #ifdef __OPTIMIZE__ case DBUS_TYPE_BYTE: - case DBUS_TYPE_BOOLEAN: case DBUS_TYPE_INT16: case DBUS_TYPE_UINT16: case DBUS_TYPE_INT32: @@ -388,6 +387,9 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) case DBUS_TYPE_DOUBLE: qIterAppend(&iterator, ba, *signature, arg.constData()); return true; + case DBUS_TYPE_BOOLEAN: + append( arg.toBool() ); + return true; #else case DBUS_TYPE_BYTE: append( qvariant_cast(arg) ); -- cgit v0.12