path: root/src/dbus/qdbusconnectionmanager_p.h
diff options
authorThiago Macieira <>2014-12-29 11:35:36 -0200
committerThiago Macieira <>2015-09-15 02:08:36 +0000
commitc2049f67e4cfe5f09e1b033b910cb37d043a287e (patch)
tree72c9760dd86acdadbcd1261443cb923ce7ed9235 /src/dbus/qdbusconnectionmanager_p.h
parent939b7c630d3f51224eacb6596f0ea2267ca5bfe5 (diff)
Use a dedicated thread for handling incoming libdbus-1 events
Each application will have one thread dedicated for this, for all QDBusConnections. I wouldn't mind sharing such a thread with other uses in Qt, provided none of them ever block (the QProcessManager thread comes to mind, but it's going away soon). The cost associated with this change in this commit is so far rather minimal. All incoming D-Bus calls need to be handled after an event is posted anyway, to avoid deadlocking on reentering libdbus-1 functions that acquire locks still held. The cost is the one more thread running and the cost of synchronizing them when an event is posted. The benefits far outweigh that cost: no longer will we have problems of QtDBus failing to run if the main system or session connections are used before QCoreApplication is run. Moreover, events can be received and handled in aux threads even if the main thread is blocked on some operation. Note: this commit may not be testable (tst_qdbusconnection may fail) Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b737556ccd11a8 Reviewed-by: Albert Astals Cid <> Reviewed-by: Alex Blasche <>
Diffstat (limited to 'src/dbus/qdbusconnectionmanager_p.h')
1 files changed, 9 insertions, 2 deletions
diff --git a/src/dbus/qdbusconnectionmanager_p.h b/src/dbus/qdbusconnectionmanager_p.h
index fc0bb515e5..c3c7999699 100644
--- a/src/dbus/qdbusconnectionmanager_p.h
+++ b/src/dbus/qdbusconnectionmanager_p.h
@@ -1,6 +1,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Intel Corporation.
** Contact:
** This file is part of the QtDBus module of the Qt Toolkit.
@@ -47,15 +48,17 @@
#include "qdbusconnection_p.h"
+#include "private/qthread_p.h"
#ifndef QT_NO_DBUS
-class QDBusConnectionManager
+class QDBusConnectionManager : public QDaemonThread
- QDBusConnectionManager() {}
+ QDBusConnectionManager();
static QDBusConnectionManager* instance();
@@ -64,6 +67,10 @@ public:
void setConnection(const QString &name, QDBusConnectionPrivate *c);
mutable QMutex mutex;
+ void run() Q_DECL_OVERRIDE;
QHash<QString, QDBusConnectionPrivate *> connectionHash;