summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-11-21 10:10:48 +0100
committerMarc Mutz <marc.mutz@kdab.com>2017-11-30 13:18:36 +0000
commit7967c40303604bf1a02fe987ffc667e4e55d9af2 (patch)
tree89eda295516f533855ff46b66ce77a48ce200bb6 /src
parent4d80d634a6edd76222c92e6f736124df5e1d345f (diff)
QThread::requestInterruption(): move qWarning() out of critical section
We do not touch anything mutex-protected in the path towards the qWarning(), so the mutex lock is not needed. It may actually be harmful, since a message handler may check isInterruptionRequested(), which would then deadlock. Otherwise, we're just decreasing the size of the critical section — always a worthwhile goal. Change-Id: I26aa7e3dc087ff7efaccff1d4dc788ba00ba183f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/thread/qthread.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index cad7a14017..20b1f01173 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -844,14 +844,14 @@ bool QThread::event(QEvent *event)
void QThread::requestInterruption()
{
- Q_D(QThread);
- QMutexLocker locker(&d->mutex);
- if (!d->running || d->finished || d->isInFinish)
- return;
if (this == QCoreApplicationPrivate::theMainThread) {
qWarning("QThread::requestInterruption has no effect on the main thread");
return;
}
+ Q_D(QThread);
+ QMutexLocker locker(&d->mutex);
+ if (!d->running || d->finished || d->isInFinish)
+ return;
d->interruptionRequested = true;
}