summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qfuturewatcher.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@theqtcompany.com>2015-09-24 11:03:38 +0200
committerEdward Welbourne <edward.welbourne@theqtcompany.com>2015-09-30 08:25:34 +0000
commitb86efb1ab9daa76965cda5bdebb225c9e3762e8e (patch)
tree78f04de08960cf5e1d79924411738e78799fcd87 /src/corelib/thread/qfuturewatcher.cpp
parent0ebebeb983d381010fae710aee60d8550d9be4f3 (diff)
Initialize QFutureWatcherBasePrivate::finished and test
It's accessed by QFutureWatcherBase::isFinished(), potentially before anything has set it. It gets to be initially true until setFuture() has given it us unfinished future and set it false. Add a regression test for matching state in future and watcher. Task-number: QTBUG-12358 Change-Id: Iae7bdaa434ab80f518afe4d7d55df99c391991a4 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'src/corelib/thread/qfuturewatcher.cpp')
-rw-r--r--src/corelib/thread/qfuturewatcher.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/thread/qfuturewatcher.cpp b/src/corelib/thread/qfuturewatcher.cpp
index 3056216f6e..3863a47673 100644
--- a/src/corelib/thread/qfuturewatcher.cpp
+++ b/src/corelib/thread/qfuturewatcher.cpp
@@ -248,7 +248,7 @@ bool QFutureWatcherBase::isStarted() const
/*! \fn bool QFutureWatcher::isFinished() const
Returns \c true if the asynchronous computation represented by the future()
- has finished; otherwise returns \c false.
+ has finished, or if no future has been set; otherwise returns \c false.
*/
bool QFutureWatcherBase::isFinished() const
{
@@ -379,7 +379,8 @@ void QFutureWatcherBase::disconnectNotify(const QMetaMethod &signal)
*/
QFutureWatcherBasePrivate::QFutureWatcherBasePrivate()
: maximumPendingResultsReady(QThread::idealThreadCount() * 2),
- resultAtConnected(0)
+ resultAtConnected(0),
+ finished(true) /* the initial m_future is a canceledResult(), with Finished set */
{ }
/*!
@@ -400,7 +401,7 @@ void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment)
d->pendingResultsReady.store(0);
qDeleteAll(d->pendingCallOutEvents);
d->pendingCallOutEvents.clear();
- d->finished = false;
+ d->finished = false; /* May soon be amended, during connectOutputInterface() */
}
futureInterface().d->disconnectOutputInterface(d_func());