From 7967c40303604bf1a02fe987ffc667e4e55d9af2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 21 Nov 2017 10:10:48 +0100 Subject: QThread::requestInterruption(): move qWarning() out of critical section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/thread/qthread.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3