Skip to content

Commit 33985fb

Browse files
author
Thiago Macieira
committed
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
1 parent 53abbf0 commit 33985fb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/dbus/qdbusmarshaller.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
378378
switch (*signature) {
379379
#ifdef __OPTIMIZE__
380380
case DBUS_TYPE_BYTE:
381-
case DBUS_TYPE_BOOLEAN:
382381
case DBUS_TYPE_INT16:
383382
case DBUS_TYPE_UINT16:
384383
case DBUS_TYPE_INT32:
@@ -388,6 +387,9 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
388387
case DBUS_TYPE_DOUBLE:
389388
qIterAppend(&iterator, ba, *signature, arg.constData());
390389
return true;
390+
case DBUS_TYPE_BOOLEAN:
391+
append( arg.toBool() );
392+
return true;
391393
#else
392394
case DBUS_TYPE_BYTE:
393395
append( qvariant_cast<uchar>(arg) );

0 commit comments

Comments
 (0)