path: root/src/dbus/qdbusconnectionmanager_p.h
diff options
authorThiago Macieira <>2015-04-03 22:46:52 -0700
committerThiago Macieira <>2015-09-15 02:08:47 +0000
commit68964b1023afa0eadee4ead5be8365b687eeec79 (patch)
tree2d55fabf6abf1f4572674d96f1ea468f79d109af /src/dbus/qdbusconnectionmanager_p.h
parentea01d7784ad3ab34061f43aa51ee91ce2339e003 (diff)
Merge two Q_GLOBAL_STATICS into another and solve memory leak
The two global statics for the session and system buses aren't necessary if they can't outlive the global static for QDBusConnectionManager anyway. So merge them there. The extra mutex is necessary because the QDBusConnection::connectToBus function will lock the regular mutex. This solves a potential memory leak at exit as a side-effect. Before this change, the session and system QDBusConnection object got destroyed in the main thread during global destruction, so it had to post an event to the QDBusConnectionManager thread to finish the destruction of the private. However, QCoreApplication is already gone by this point, so the QEvent::DeferredDelete event never got delivered. After this commit, there's no global static to destroy the QDBusConnection (there is no QDBusConnection holding a reference), so the object gets destroyed in QDBusConnectionManager::run()'s cleanup code. Change-Id: I9a75ad8521ae4e5cbbe5ffff13d1b967ee1a7a7e Reviewed-by: Albert Astals Cid <> Reviewed-by: Alex Blasche <>
Diffstat (limited to 'src/dbus/qdbusconnectionmanager_p.h')
1 files changed, 4 insertions, 0 deletions
diff --git a/src/dbus/qdbusconnectionmanager_p.h b/src/dbus/qdbusconnectionmanager_p.h
index 4527c562f8..3f815fdcd7 100644
--- a/src/dbus/qdbusconnectionmanager_p.h
+++ b/src/dbus/qdbusconnectionmanager_p.h
@@ -63,6 +63,7 @@ public:
static QDBusConnectionManager* instance();
+ QDBusConnectionPrivate *busConnection(QDBusConnection::BusType type);
QDBusConnectionPrivate *connection(const QString &name) const;
void removeConnection(const QString &name);
void setConnection(const QString &name, QDBusConnectionPrivate *c);
@@ -85,6 +86,9 @@ private:
QHash<QString, QDBusConnectionPrivate *> connectionHash;
+ QMutex defaultBusMutex;
+ QDBusConnectionPrivate *defaultBuses[2];
mutable QMutex senderMutex;
QString senderName; // internal; will probably change