diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-08-24 16:57:18 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-08-26 16:37:43 +0200 |
commit | 9efe2a8603cd9023bfebb96a3a7ca4a65002669d (patch) | |
tree | 230b058b4cc37b546f6a38bfe3b90d4e032f73f4 /src/corelib/thread/qfutureinterface.cpp | |
parent | 7d35e31efb1a58c529ffefc4a5941511024eeabc (diff) |
Fix QFuture::waitForFinished to wait until QFuture is started
Currently QFuture::waitForFinished() exits as soon as the future is not
in the running state. If the user calls it before
QPromise::reportStarted() is called, it will exit immediately, because
nothing is running yet. Fix the behavior to wait for the finished state.
[ChangeLog][Important Behavior Changes][QtCore] Fixed the behavior of
QFuture::waitForFinished() to wait until the future is actually in the
finished state, instead of exiting as soon as it is not in the running
state. This prevents waitForFinished() from exiting immediately, if at
the moment of calling it the future is not started yet.
Task-number: QTBUG-84867
Change-Id: I12f5e95d8200cfffa5653b6aa566a625f8320ca8
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/thread/qfutureinterface.cpp')
-rw-r--r-- | src/corelib/thread/qfutureinterface.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index a625e05aac..600dd9bd3f 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -422,7 +422,7 @@ void QFutureInterfaceBase::waitForResult(int resultIndex) void QFutureInterfaceBase::waitForFinished() { QMutexLocker lock(&d->m_mutex); - const bool alreadyFinished = !isRunningOrPending(); + const bool alreadyFinished = isFinished(); lock.unlock(); if (!alreadyFinished) { @@ -430,7 +430,7 @@ void QFutureInterfaceBase::waitForFinished() lock.relock(); - while (isRunningOrPending()) + while (!isFinished()) d->waitCondition.wait(&d->m_mutex); } |