diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-08 15:59:00 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-12-08 15:59:00 (GMT) |
commit | ccc3497c8815c1bc686a85a88ca2810f99a0c1eb (patch) | |
tree | b44dc4d1e1fe9853c657b925b5efc8668dacf42b /src/corelib/kernel | |
parent | 2bfb839c3ff90b52e52ef032e513b70789139d5c (diff) | |
download | Qt-ccc3497c8815c1bc686a85a88ca2810f99a0c1eb.zip Qt-ccc3497c8815c1bc686a85a88ca2810f99a0c1eb.tar.gz Qt-ccc3497c8815c1bc686a85a88ca2810f99a0c1eb.tar.bz2 |
Small optimisations in ~QObject
Avoid calling signalSlotMutex while there is a very small
probability that the node will be different or that the mutex
are the same for two different object.
Reviewed-by: brad
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qobject.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 7669ee1..91bf4ae 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -914,7 +914,8 @@ QObject::~QObject() // disconnect all receivers if (d->connectionLists) { ++d->connectionLists->inUse; - for (int signal = -1; signal < d->connectionLists->count(); ++signal) { + int connectionListsCount = d->connectionLists->count(); + for (int signal = -1; signal < connectionListsCount; ++signal) { QObjectPrivate::ConnectionList &connectionList = (*d->connectionLists)[signal]; @@ -951,16 +952,17 @@ QObject::~QObject() // disconnect all senders QObjectPrivate::Connection *node = d->senders; while (node) { - QMutex *m = signalSlotLock(node->sender); + QObject *sender = node->sender; + QMutex *m = signalSlotLock(sender); node->prev = &node; bool needToUnlock = QOrderedMutexLocker::relock(locker.mutex(), m); //the node has maybe been removed while the mutex was unlocked in relock? - if (!node || signalSlotLock(node->sender) != m) { + if (!node || node->sender != sender) { m->unlock(); continue; } node->receiver = 0; - QObjectConnectionListVector *senderLists = node->sender->d_func()->connectionLists; + QObjectConnectionListVector *senderLists = sender->d_func()->connectionLists; if (senderLists) senderLists->dirty = true; |