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>
This commit is contained in:
parent
4d80d634a6
commit
7967c40303
@ -844,14 +844,14 @@ bool QThread::event(QEvent *event)
|
|||||||
|
|
||||||
void QThread::requestInterruption()
|
void QThread::requestInterruption()
|
||||||
{
|
{
|
||||||
Q_D(QThread);
|
|
||||||
QMutexLocker locker(&d->mutex);
|
|
||||||
if (!d->running || d->finished || d->isInFinish)
|
|
||||||
return;
|
|
||||||
if (this == QCoreApplicationPrivate::theMainThread) {
|
if (this == QCoreApplicationPrivate::theMainThread) {
|
||||||
qWarning("QThread::requestInterruption has no effect on the main thread");
|
qWarning("QThread::requestInterruption has no effect on the main thread");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Q_D(QThread);
|
||||||
|
QMutexLocker locker(&d->mutex);
|
||||||
|
if (!d->running || d->finished || d->isInFinish)
|
||||||
|
return;
|
||||||
d->interruptionRequested = true;
|
d->interruptionRequested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user