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>
bb10
parent
4213f23936
commit
030b17ecc0
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue