diff options
Diffstat (limited to 'src/corelib/thread/qfutureinterface.cpp')
| -rw-r--r-- | src/corelib/thread/qfutureinterface.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 7f1b2bef154..2236b5d1db1 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -888,6 +888,7 @@ void QFutureInterfaceBase::setContinuation(std::function<void(const QFutureInter // If the state is ready, run continuation immediately, // otherwise save it for later. if (isFinished()) { + d->continuationExecuted = true; lock.unlock(); func(*this); lock.relock(); @@ -919,10 +920,11 @@ void QFutureInterfaceBase::cleanContinuation() void QFutureInterfaceBase::runContinuation() const { QMutexLocker lock(&d->continuationMutex); - if (d->continuation) { + if (d->continuation && !d->continuationExecuted) { // Save the continuation in a local function, to avoid calling // a null std::function below, in case cleanContinuation() is // called from some other thread right after unlock() below. + d->continuationExecuted = true; auto fn = std::move(d->continuation); lock.unlock(); fn(*this); |
