From b86efb1ab9daa76965cda5bdebb225c9e3762e8e Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 24 Sep 2015 11:03:38 +0200 Subject: Initialize QFutureWatcherBasePrivate::finished and test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Thiago Macieira Reviewed-by: Jędrzej Nowacki --- src/corelib/thread/qfuturewatcher.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/corelib/thread/qfuturewatcher.cpp') 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()); -- cgit v1.2.3