summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qobject.cpp
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-06-25 20:19:11 +0200
committerQt by Nokia <qt-info@nokia.com>2012-06-28 14:44:20 +0200
commitd359b0af2b93aeb9c22714be1cec881417650ed8 (patch)
treeedc793d9197500d094c5ee9a01ba3ce252b36c5a /src/corelib/kernel/qobject.cpp
parent26c85a5f79875a25367527462e8d0864021078ab (diff)
Call QObject::disconnectNotify() when receiver is destroyed
Store the signal index in QObjectPrivate::Connection, thereby making it available in "implicit" disconnect contexts (i.e., receiver deletion). This change does not cause the size of QObjectPrivate::Connection to grow (still 40 bytes on 32-bit Linux, 72 bytes on 64-bit Mac). Valgrinding the new benchmark indicates that the percentage of the time spent in the QObject destructor increased from 7.8% to 8.4% on ia32, for that particular stress test; the increase is the combined cost of calling metaObject(), QMetaObjectPrivate::signal(), and disconnectNotify() for one connection. In practice, the measured wallclock time increased by about 3ms for a 500ms run (which repeatedly constructs, connects, and destroys an object). Task-number: QTBUG-4844 Change-Id: I1beb01c753f31542fc0acb62edb4c6d165fcc5b4 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Diffstat (limited to 'src/corelib/kernel/qobject.cpp')
-rw-r--r--src/corelib/kernel/qobject.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index bcbc45cdbe..c0bb812904 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -831,9 +831,11 @@ QObject::~QObject()
if (senderLists)
senderLists->dirty = true;
+ int signal_index = node->signal_index;
node = node->next;
if (needToUnlock)
m->unlock();
+ sender->disconnectNotify(QMetaObjectPrivate::signal(sender->metaObject(), signal_index));
}
}
@@ -3021,6 +3023,7 @@ QObjectPrivate::Connection *QMetaObjectPrivate::connect(const QObject *sender,
QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
c->sender = s;
+ c->signal_index = signal_index;
c->receiver = r;
c->method_relative = method_index;
c->method_offset = method_offset;
@@ -4188,6 +4191,7 @@ QMetaObject::Connection QObject::connectImpl(const QObject *sender, void **signa
QScopedPointer<QObjectPrivate::Connection> c(new QObjectPrivate::Connection);
c->sender = s;
+ c->signal_index = signal_index;
c->receiver = r;
c->slotObj = slotObj;
c->connectionType = type;