diff --git a/src/concurrent/qtconcurrentthreadengine.cpp b/src/concurrent/qtconcurrentthreadengine.cpp index 3293c49507d..cf424912b37 100644 --- a/src/concurrent/qtconcurrentthreadengine.cpp +++ b/src/concurrent/qtconcurrentthreadengine.cpp @@ -322,10 +322,13 @@ void ThreadEngineBase::run() // implements QRunnable. void ThreadEngineBase::handleException(const QException &exception) { - if (futureInterface) + if (futureInterface) { futureInterface->reportException(exception); - else if (!exceptionStore.hasException()) - exceptionStore.setException(exception); + } else { + QMutexLocker lock(&mutex); + if (!exceptionStore.hasException()) + exceptionStore.setException(exception); + } } #endif diff --git a/src/concurrent/qtconcurrentthreadengine.h b/src/concurrent/qtconcurrentthreadengine.h index af413707e49..b7be48d6125 100644 --- a/src/concurrent/qtconcurrentthreadengine.h +++ b/src/concurrent/qtconcurrentthreadengine.h @@ -121,6 +121,7 @@ protected: QThreadPool *threadPool; ThreadEngineBarrier barrier; QtPrivate::ExceptionStore exceptionStore; + QBasicMutex mutex; };