Skip to content

Commit

Permalink
Merge pull request #30039 from rouault/wfs_fix_ghost_progress_dialog
Browse files Browse the repository at this point in the history
[WFS provider] Avoid dangling download progress dialog
  • Loading branch information
rouault authored Jun 5, 2019
2 parents 9c91505 + d772210 commit 4662bb9
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
Original file line number Diff line number Diff line change
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 @@ -834,7 +840,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 @@ -857,6 +866,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
Original file line number Diff line number Diff line change
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 4662bb9

Please sign in to comment.