Skip to content

Commit

Permalink
Merge pull request #30101 from qgis/backport-30039-to-release-3_4
Browse files Browse the repository at this point in the history
[Backport release-3_4] [WFS provider] Avoid dangling download progress dialog
  • Loading branch information
rouault committed Jun 5, 2019
2 parents 0deda6c + 66d05b8 commit 393983f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/providers/wfs/qgswfsfeatureiterator.cpp
Expand Up @@ -165,6 +165,12 @@ void QgsWFSFeatureDownloader::createProgressDialog()
{
Q_ASSERT( qApp->thread() == QThread::currentThread() );

// Make sure that the creation is done in an atomic way, so that the
// starting thread (running QgsWFSFeatureDownloader::run()) can be sure that
// this function has either run completely, or not at all (mStop == true),
// when it wants to destroy mProgressDialog
QMutexLocker locker( &mMutexCreateProgressDialog );

if ( mStop )
return;
Q_ASSERT( !mProgressDialog );
Expand Down Expand Up @@ -833,7 +839,10 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )
}
}

mStop = true;
{
QMutexLocker locker( &mMutexCreateProgressDialog );
mStop = true;
}

if ( serializeFeatures )
mShared->endOfDownload( success, mTotalDownloadedFeatureCount, truncatedResponse, interrupted, mErrorMessage );
Expand All @@ -856,6 +865,7 @@ void QgsWFSFeatureDownloader::run( bool serializeFeatures, int maxFeatures )
mTimer->deleteLater();
mTimer = nullptr;
}

// explicitly abort here so that mReply is destroyed within the right thread
// otherwise will deadlock because deleteLayer() will not have a valid thread to post
abort();
Expand Down
1 change: 1 addition & 0 deletions src/providers/wfs/qgswfsfeatureiterator.h
Expand Up @@ -158,6 +158,7 @@ class QgsWFSFeatureDownloader: public QgsWfsRequest
QTimer *mTimer = nullptr;
QgsWFSFeatureHitsAsyncRequest mFeatureHitsAsyncRequest;
qint64 mTotalDownloadedFeatureCount;
QMutex mMutexCreateProgressDialog;
};

//! Downloader thread
Expand Down

0 comments on commit 393983f

Please sign in to comment.