@@ -3337,7 +3337,18 @@ QgsWmsImageDownloadHandler::QgsWmsImageDownloadHandler( const QString& providerU
3337
3337
: mProviderUri( providerUri )
3338
3338
, mCachedImage( image )
3339
3339
, mEventLoop( new QEventLoop )
3340
+ , mFeedback( feedback )
3340
3341
{
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
+
3341
3352
QNetworkRequest request ( url );
3342
3353
auth.setAuthorization ( request );
3343
3354
request.setAttribute ( QNetworkRequest::CacheSaveControlAttribute, true );
@@ -3346,9 +3357,6 @@ QgsWmsImageDownloadHandler::QgsWmsImageDownloadHandler( const QString& providerU
3346
3357
connect ( mCacheReply , SIGNAL ( downloadProgress ( qint64, qint64 ) ), this , SLOT ( cacheReplyProgress ( qint64, qint64 ) ) );
3347
3358
3348
3359
Q_ASSERT ( mCacheReply ->thread () == QThread::currentThread () );
3349
-
3350
- if ( feedback )
3351
- connect ( feedback, SIGNAL ( cancelled () ), this , SLOT ( cancelled () ), Qt::QueuedConnection );
3352
3360
}
3353
3361
3354
3362
QgsWmsImageDownloadHandler::~QgsWmsImageDownloadHandler ()
@@ -3358,6 +3366,9 @@ QgsWmsImageDownloadHandler::~QgsWmsImageDownloadHandler()
3358
3366
3359
3367
void QgsWmsImageDownloadHandler::downloadBlocking ()
3360
3368
{
3369
+ if ( mFeedback && mFeedback ->isCancelled () )
3370
+ return ; // nothing to do
3371
+
3361
3372
mEventLoop ->exec ( QEventLoop::ExcludeUserInputEvents );
3362
3373
3363
3374
Q_ASSERT ( !mCacheReply );
@@ -3497,6 +3508,16 @@ QgsWmsTiledImageDownloadHandler::QgsWmsTiledImageDownloadHandler( const QString&
3497
3508
, mSmoothPixmapTransform( smoothPixmapTransform )
3498
3509
, mFeedback( feedback )
3499
3510
{
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
+
3500
3521
Q_FOREACH ( const TileRequest& r, requests )
3501
3522
{
3502
3523
QNetworkRequest request ( r.url );
@@ -3513,9 +3534,6 @@ QgsWmsTiledImageDownloadHandler::QgsWmsTiledImageDownloadHandler( const QString&
3513
3534
3514
3535
mReplies << reply;
3515
3536
}
3516
-
3517
- if ( feedback )
3518
- connect ( feedback, SIGNAL ( cancelled () ), this , SLOT ( cancelled () ), Qt::QueuedConnection );
3519
3537
}
3520
3538
3521
3539
QgsWmsTiledImageDownloadHandler::~QgsWmsTiledImageDownloadHandler ()
@@ -3525,6 +3543,9 @@ QgsWmsTiledImageDownloadHandler::~QgsWmsTiledImageDownloadHandler()
3525
3543
3526
3544
void QgsWmsTiledImageDownloadHandler::downloadBlocking ()
3527
3545
{
3546
+ if ( mFeedback && mFeedback ->isCancelled () )
3547
+ return ; // nothing to do
3548
+
3528
3549
mEventLoop ->exec ( QEventLoop::ExcludeUserInputEvents );
3529
3550
3530
3551
Q_ASSERT ( mReplies .isEmpty () );
0 commit comments