From 5e3f770ad5e47f296b4782c0b6c5b03162027500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Thu, 18 Aug 2016 11:44:45 +0200 Subject: Fix problem with exception reporting in QFuture::waitForResult() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a problem that occurs when a task, that is run synchronously, throws an exception. If that happened, then the exception would not be re-thrown, because of an early return. Task-number: QTBUG-54831 Change-Id: Ic70c5b810ec6adce6e62bfd6832ba9f170b13a7f Reviewed-by: Jędrzej Nowacki --- src/corelib/thread/qfutureinterface.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/corelib/thread') diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 60155c96fd..2fe038165b 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -299,12 +299,11 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) lock.relock(); - if (!(d->state & Running)) - return; - - const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; - while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) - d->waitCondition.wait(&d->m_mutex); + if (d->state & Running) { + const int waitIndex = (resultIndex == -1) ? INT_MAX : resultIndex; + while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) + d->waitCondition.wait(&d->m_mutex); + } d->m_exceptionStore.throwPossibleException(); } -- cgit v1.2.3