From 7e9f7080b764524d2a7c7a410a4cebed22f3b16d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 19 Apr 2012 12:24:25 +1000 Subject: [PATCH] Minor QObject::receivers() optimization. Don't lock if there are no receivers. Change-Id: I922fad10436adeb27aa4f193cc0dcbaa3f0c0f1e Reviewed-by: Kent Hansen Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobject.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index e35da8085e..a633f503a7 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2190,6 +2190,9 @@ int QObject::receivers(const char *signal) const metaObject()->indexOfMethod(signal)); } + if (!d->isSignalConnected(signal_index)) + return receivers; + QMutexLocker locker(signalSlotLock(this)); if (d->connectionLists) { if (signal_index < d->connectionLists->count()) {