From c4f433d581e2d609d2eaecc4e4b999a469950eb3 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sun, 16 Dec 2012 23:06:45 +0100 Subject: Reset the QMetaObject::Connection dptr when disconnect()ing The QObjectPrivate::Connection refcount was not decreased when disconnect()ing, therefore it was kept alive by the owning QMetaObject::Connection object. This removes a leak in case the QMetaObject::Connection survives the sender object, after a successful disconnect(). Change-Id: Ie2ea59b269a0e589ae23c1457df7533be77c0797 Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobject.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0a3db0cd06..20c634ad78 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4293,6 +4293,10 @@ bool QObject::disconnect(const QMetaObject::Connection &connection) if (c->next) c->next->prev = c->prev; c->receiver = 0; + + const_cast(connection).d_ptr = 0; + c->deref(); // has been removed from the QMetaObject::Connection object + // disconnectNotify() not called (the signal index is unknown). return true; -- cgit v1.2.3