File Make-QDBusConnectionPrivaterelaySignal-be-called-in-the-right-thread.patch of Package libqt5-qtbase.16542

From ebf0b121084822ce754c14ed7255bde0f90bf42f Mon Sep 17 00:00:00 2001
From: Thiago Macieira <>
Date: Tue, 6 Sep 2016 11:41:00 -0700
Subject: [PATCH] Make QDBusConnectionPrivate::relaySignal be called in the
 right thread

This function sends D-Bus messages directly (in huntAndEmit), so it
should only be called from the QDBusConnectionManager thread. Somehow, I
missed this in the Qt 5.6 refactoring of QtDBus.

Being called in the wrong thread means that there's a visible behavior
change compared to Qt 5.5: if the user code sent a method call or method
return/error and then emitted a signal, we'd have two threads racing to
send the D-Bus messages. This was observed in Telepathy-Qt code: certain
signals arrived before a method return, even though they were clearly
emitted by a queued QMetaObject::invokeMethod.

In addition to that, we have has an internal problem (though not
observed): the libdbus-1 timer and socket callbacks would be called in
the wrong thread and we no longer have protection against that.

Unit testing not possible since this is a race condition.

Change-Id: I9e96ecd4f6aa4ff0ae08fffd1471d002142613d6
Reviewed-by: Gustavo Pichorim Boiko <>
Reviewed-by: Alex Blasche <>
 src/dbus/qdbusintegrator.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 878a582..c2cf7f4 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1257,6 +1257,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
+    checkThread();
     QDBusReadLocker locker(RelaySignalAction, this);
     QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/"), interface,
@@ -2368,12 +2369,9 @@ void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
-        // disconnect and reconnect to avoid duplicates
-        connector->disconnect(SIGNAL(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
-                              this, SLOT(relaySignal(QObject*,const QMetaObject*,int,QVariantList)));
         connect(connector, SIGNAL(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
                 this, SLOT(relaySignal(QObject*,const QMetaObject*,int,QVariantList)),
-                Qt::DirectConnection);
+                Qt::ConnectionType(Qt::QueuedConnection | Qt::UniqueConnection));
openSUSE Build Service is sponsored by