Skip to content

Commit 50258e6

Browse files
committed
Cancel WCS requests just like it is done in WMS
1 parent 08f4a0f commit 50258e6

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/providers/wcs/qgswcsprovider.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,18 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorizati
16631663
, mCachedData( cachedData )
16641664
, mWcsVersion( wcsVersion )
16651665
, mCachedError( cachedError )
1666+
, mFeedback( feedback )
16661667
{
1668+
if ( feedback )
1669+
{
1670+
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );
1671+
1672+
// rendering could have been cancelled before we started to listen to cancelled() signal
1673+
// so let's check before doing the download and maybe quit prematurely
1674+
if ( feedback->isCancelled() )
1675+
return;
1676+
}
1677+
16671678
QNetworkRequest request( url );
16681679
if ( !mAuth.setAuthorization( request ) )
16691680
{
@@ -1677,9 +1688,6 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorizati
16771688
mCacheReply = QgsNetworkAccessManager::instance()->get( request );
16781689
connect( mCacheReply, SIGNAL( finished() ), this, SLOT( cacheReplyFinished() ) );
16791690
connect( mCacheReply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( cacheReplyProgress( qint64, qint64 ) ) );
1680-
1681-
if ( feedback )
1682-
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );
16831691
}
16841692

16851693
QgsWcsDownloadHandler::~QgsWcsDownloadHandler()
@@ -1689,6 +1697,9 @@ QgsWcsDownloadHandler::~QgsWcsDownloadHandler()
16891697

16901698
void QgsWcsDownloadHandler::blockingDownload()
16911699
{
1700+
if ( mFeedback && mFeedback->isCancelled() )
1701+
return; // nothing to do
1702+
16921703
mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );
16931704

16941705
Q_ASSERT( !mCacheReply );

src/providers/wcs/qgswcsprovider.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ class QgsWcsDownloadHandler : public QObject
441441
QString mWcsVersion;
442442
QgsError& mCachedError;
443443

444+
QgsRasterBlockFeedback* mFeedback;
445+
444446
static int sErrors; // this should be ideally per-provider...?
445447
};
446448

0 commit comments

Comments
 (0)