Minor optimization

Avoid calling QThread::current() in many cases.

Change-Id: Iac2e8ff1a72e3d39b6efa7e94239abbce29924ac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Lars Knoll 2018-12-17 13:49:51 +01:00
parent c497f79ad4
commit f7d7d7c81c

View File

@ -2257,9 +2257,9 @@ bool QMetaMethod::invoke(QObject *object,
return false;
// check connection type
QThread *currentThread = QThread::currentThread();
QThread *objectThread = object->thread();
if (connectionType == Qt::AutoConnection) {
QThread *currentThread = QThread::currentThread();
QThread *objectThread = object->thread();
connectionType = currentThread == objectThread
? Qt::DirectConnection
: Qt::QueuedConnection;
@ -2342,6 +2342,8 @@ bool QMetaMethod::invoke(QObject *object,
0, -1, nargs, types, args));
} else { // blocking queued connection
#if QT_CONFIG(thread)
QThread *currentThread = QThread::currentThread();
QThread *objectThread = object->thread();
if (currentThread == objectThread) {
qWarning("QMetaMethod::invoke: Dead lock detected in "
"BlockingQueuedConnection: Receiver is %s(%p)",