diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2015-04-03 22:46:52 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-09-15 02:08:47 +0000 |
commit | 68964b1023afa0eadee4ead5be8365b687eeec79 (patch) | |
tree | 2d55fabf6abf1f4572674d96f1ea468f79d109af /src/dbus/qdbusintegrator.cpp | |
parent | ea01d7784ad3ab34061f43aa51ee91ce2339e003 (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 <aacid@kde.org>
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/dbus/qdbusintegrator.cpp')
-rw-r--r-- | src/dbus/qdbusintegrator.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 9b0a51107a..22598a2f2d 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1043,6 +1043,10 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate() "Timer and socket errors will follow and the program will probably crash", qPrintable(name)); + closeConnection(); + rootNode.children.clear(); // free resources + qDeleteAll(cachedMetaObjects); + if (mode == ClientMode) { // the bus service object holds a reference back to us; // we need to destroy it before we finish destroying ourselves @@ -1052,10 +1056,6 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate() delete obj; } - closeConnection(); - rootNode.children.clear(); // free resources - qDeleteAll(cachedMetaObjects); - if (server) q_dbus_server_unref(server); if (connection) |