Skip to content

Commit 8d832d8

Browse files
committed
Make sure we do not miss cancellation request at the beginning
1 parent fdeac81 commit 8d832d8

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

src/providers/wms/qgswmsprovider.cpp

+27-6
Original file line numberDiff line numberDiff line change
@@ -3337,7 +3337,18 @@ QgsWmsImageDownloadHandler::QgsWmsImageDownloadHandler( const QString& providerU
33373337
: mProviderUri( providerUri )
33383338
, mCachedImage( image )
33393339
, mEventLoop( new QEventLoop )
3340+
, mFeedback( feedback )
33403341
{
3342+
if ( feedback )
3343+
{
3344+
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );
3345+
3346+
// rendering could have been cancelled before we started to listen to cancelled() signal
3347+
// so let's check before doing the download and maybe quit prematurely
3348+
if ( feedback->isCancelled() )
3349+
return;
3350+
}
3351+
33413352
QNetworkRequest request( url );
33423353
auth.setAuthorization( request );
33433354
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
@@ -3346,9 +3357,6 @@ QgsWmsImageDownloadHandler::QgsWmsImageDownloadHandler( const QString& providerU
33463357
connect( mCacheReply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( cacheReplyProgress( qint64, qint64 ) ) );
33473358

33483359
Q_ASSERT( mCacheReply->thread() == QThread::currentThread() );
3349-
3350-
if ( feedback )
3351-
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );
33523360
}
33533361

33543362
QgsWmsImageDownloadHandler::~QgsWmsImageDownloadHandler()
@@ -3358,6 +3366,9 @@ QgsWmsImageDownloadHandler::~QgsWmsImageDownloadHandler()
33583366

33593367
void QgsWmsImageDownloadHandler::downloadBlocking()
33603368
{
3369+
if ( mFeedback && mFeedback->isCancelled() )
3370+
return; // nothing to do
3371+
33613372
mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
33623373

33633374
Q_ASSERT( !mCacheReply );
@@ -3497,6 +3508,16 @@ QgsWmsTiledImageDownloadHandler::QgsWmsTiledImageDownloadHandler( const QString&
34973508
, mSmoothPixmapTransform( smoothPixmapTransform )
34983509
, mFeedback( feedback )
34993510
{
3511+
if ( feedback )
3512+
{
3513+
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );
3514+
3515+
// rendering could have been cancelled before we started to listen to cancelled() signal
3516+
// so let's check before doing the download and maybe quit prematurely
3517+
if ( feedback->isCancelled() )
3518+
return;
3519+
}
3520+
35003521
Q_FOREACH ( const TileRequest& r, requests )
35013522
{
35023523
QNetworkRequest request( r.url );
@@ -3513,9 +3534,6 @@ QgsWmsTiledImageDownloadHandler::QgsWmsTiledImageDownloadHandler( const QString&
35133534

35143535
mReplies << reply;
35153536
}
3516-
3517-
if ( feedback )
3518-
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );
35193537
}
35203538

35213539
QgsWmsTiledImageDownloadHandler::~QgsWmsTiledImageDownloadHandler()
@@ -3525,6 +3543,9 @@ QgsWmsTiledImageDownloadHandler::~QgsWmsTiledImageDownloadHandler()
35253543

35263544
void QgsWmsTiledImageDownloadHandler::downloadBlocking()
35273545
{
3546+
if ( mFeedback && mFeedback->isCancelled() )
3547+
return; // nothing to do
3548+
35283549
mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
35293550

35303551
Q_ASSERT( mReplies.isEmpty() );

src/providers/wms/qgswmsprovider.h

+2
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ class QgsWmsImageDownloadHandler : public QObject
571571
QImage* mCachedImage;
572572

573573
QEventLoop* mEventLoop;
574+
575+
QgsRasterBlockFeedback* mFeedback;
574576
};
575577

576578

0 commit comments

Comments
 (0)