Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cancel WCS requests just like it is done in WMS
(cherry picked from commit 50258e6)
  • Loading branch information
wonder-sk committed Oct 28, 2016
1 parent aeeb5d9 commit ed3b071
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/providers/wcs/qgswcsprovider.cpp
Expand Up @@ -1653,7 +1653,18 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorizati
, mCachedData( cachedData )
, mWcsVersion( wcsVersion )
, mCachedError( cachedError )
, mFeedback( feedback )
{
if ( feedback )
{
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );

// rendering could have been cancelled before we started to listen to cancelled() signal
// so let's check before doing the download and maybe quit prematurely
if ( feedback->isCancelled() )
return;
}

QNetworkRequest request( url );
if ( !mAuth.setAuthorization( request ) )
{
Expand All @@ -1676,9 +1687,6 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorizati
}
connect( mCacheReply, SIGNAL( finished() ), this, SLOT( cacheReplyFinished() ) );
connect( mCacheReply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( cacheReplyProgress( qint64, qint64 ) ) );

if ( feedback )
connect( feedback, SIGNAL( cancelled() ), this, SLOT( cancelled() ), Qt::QueuedConnection );
}

QgsWcsDownloadHandler::~QgsWcsDownloadHandler()
Expand All @@ -1688,6 +1696,9 @@ QgsWcsDownloadHandler::~QgsWcsDownloadHandler()

void QgsWcsDownloadHandler::blockingDownload()
{
if ( mFeedback && mFeedback->isCancelled() )
return; // nothing to do

mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );

Q_ASSERT( !mCacheReply );
Expand Down
2 changes: 2 additions & 0 deletions src/providers/wcs/qgswcsprovider.h
Expand Up @@ -443,6 +443,8 @@ class QgsWcsDownloadHandler : public QObject
QString mWcsVersion;
QgsError& mCachedError;

QgsRasterBlockFeedback* mFeedback;

static int sErrors; // this should be ideally per-provider...?
};

Expand Down

0 comments on commit ed3b071

Please sign in to comment.