Fix qgstaskmanager waitforfinished so it waits that the task was

actually started
This commit is contained in:
Julien Cabieces 2019-10-21 09:39:32 +02:00 committed by Nyall Dawson
parent c7e7baaaa8
commit 42e22b7a68
2 changed files with 7 additions and 0 deletions

View File

@ -29,6 +29,7 @@ QgsTask::QgsTask( const QString &name, Flags flags )
: mFlags( flags )
, mDescription( name )
{
mNotStartedMutex.lock();
}
QgsTask::~QgsTask()
@ -41,6 +42,7 @@ QgsTask::~QgsTask()
delete subTask.task;
}
mNotFinishedMutex.unlock();
mNotStartedMutex.unlock();
}
void QgsTask::setDescription( const QString &description )
@ -55,6 +57,7 @@ qint64 QgsTask::elapsedTime() const
void QgsTask::start()
{
mNotStartedMutex.unlock();
mNotFinishedMutex.lock();
mStartCount++;
Q_ASSERT( mStartCount == 1 );
@ -152,6 +155,9 @@ QList<QgsMapLayer *> QgsTask::dependentLayers() const
bool QgsTask::waitForFinished( int timeout )
{
// We wait the task to be started
mNotStartedMutex.lock();
bool rv = true;
if ( mOverallStatus == Complete || mOverallStatus == Terminated )
{

View File

@ -310,6 +310,7 @@ class CORE_EXPORT QgsTask : public QObject
* it's used as a trigger for waitForFinished.
*/
QMutex mNotFinishedMutex;
QMutex mNotStartedMutex;
//! Progress of this (parent) task alone
double mProgress = 0.0;