diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-07-21 10:59:44 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-07-23 09:58:34 +0000 |
commit | c4012ff5f08c02840ef42216e1273b08e6bf5234 (patch) | |
tree | 2fa43605f42224ef2c009c5213983ae747fb12ce /src | |
parent | 5ad344231c650d2be877aac6d28d3a7710d7d178 (diff) |
Make QFutureWatcher::isFinished() consistent with the watched QFuture
All the getters of QFutureWatcher are consistent with the getters of the
corresponding QFuture, except for the isFinished() method, which returns
'true' only after the finished() signal is delivered. This behavior
might be unintuitive for the users. In particular, isFinished() returns
'false', even if it's called immediately after waitForFinished().
[ChangeLog][QtCore][QFutureWatcher][Important Behavior Changes] The
QFutureWatcher::isFinished() method now indicates if the related
QFuture is finished, instead of indicating if the finished() signal was
delivered. This makes it consistent with the future that is being
watched.
Fixes: QTBUG-91048
Change-Id: I6ae9b882b23e06198a82c95b026491bd480b3bf0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 53e4a50c6b3c7359b9afc24f30c9517abdf9561a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/thread/qfuturewatcher.cpp | 8 | ||||
-rw-r--r-- | src/corelib/thread/qfuturewatcher_p.h | 1 |
2 files changed, 2 insertions, 7 deletions
diff --git a/src/corelib/thread/qfuturewatcher.cpp b/src/corelib/thread/qfuturewatcher.cpp index d59b6755a4..530539ca4e 100644 --- a/src/corelib/thread/qfuturewatcher.cpp +++ b/src/corelib/thread/qfuturewatcher.cpp @@ -329,8 +329,7 @@ bool QFutureWatcherBase::isStarted() const */ bool QFutureWatcherBase::isFinished() const { - Q_D(const QFutureWatcherBase); - return d->finished; + return futureInterface().isFinished(); } /*! \fn template <typename T> bool QFutureWatcher<T>::isRunning() const @@ -480,8 +479,7 @@ void QFutureWatcherBase::disconnectNotify(const QMetaMethod &signal) */ QFutureWatcherBasePrivate::QFutureWatcherBasePrivate() : maximumPendingResultsReady(QThread::idealThreadCount() * 2), - resultAtConnected(0), - finished(true) /* the initial m_future is a canceledResult(), with Finished set */ + resultAtConnected(0) { } /*! @@ -500,7 +498,6 @@ void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment) if (pendingAssignment) { Q_D(QFutureWatcherBase); d->pendingResultsReady.storeRelaxed(0); - d->finished = false; /* May soon be amended, during connectOutputInterface() */ } futureInterface().d->disconnectOutputInterface(d_func()); @@ -532,7 +529,6 @@ void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event) emit q->started(); break; case QFutureCallOutEvent::Finished: - finished = true; emit q->finished(); break; case QFutureCallOutEvent::Canceled: diff --git a/src/corelib/thread/qfuturewatcher_p.h b/src/corelib/thread/qfuturewatcher_p.h index b086b88773..f9a628e4fb 100644 --- a/src/corelib/thread/qfuturewatcher_p.h +++ b/src/corelib/thread/qfuturewatcher_p.h @@ -78,7 +78,6 @@ public: int maximumPendingResultsReady; QAtomicInt resultAtConnected; - bool finished; }; QT_END_NAMESPACE |