summaryrefslogtreecommitdiffstats
path: root/src/dbus
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2018-11-22 11:58:14 +0100
committerKirill Burtsev <kirill.burtsev@qt.io>2018-11-28 11:19:34 +0000
commit030b17ecc099ab3191b9b7a43a61560cf3d43f29 (patch)
tree7dbb945ef420d372a4aa7618efeec7dc3370a10f /src/dbus
parent4213f239361e042ae5a053e3eaa87931b6696caf (diff)
QDBusConnection: prevent leaking connection/server on destroy
Amends fix 68964b1023 Change-Id: I05816f4b4d2128ed0b669e124d9c9eef92122ec0 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/dbus')
-rw-r--r--src/dbus/qdbusintegrator.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 03de5b0091..dfef25e3a8 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -1062,10 +1062,11 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate()
"Timer and socket errors will follow and the program will probably crash",
qPrintable(name));
+ auto lastMode = mode; // reset on connection close
closeConnection();
qDeleteAll(cachedMetaObjects);
- if (mode == ClientMode || mode == PeerMode) {
+ if (lastMode == ClientMode || lastMode == PeerMode) {
// the bus service object holds a reference back to us;
// we need to destroy it before we finish destroying ourselves
Q_ASSERT(ref.load() == 0);
@@ -1077,7 +1078,7 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate()
if (connection)
q_dbus_connection_unref(connection);
connection = 0;
- } else if (mode == ServerMode) {
+ } else if (lastMode == ServerMode) {
if (server)
q_dbus_server_unref(server);
server = 0;