Skip to content
Permalink
Browse files

Cancel WCS requests just like it is done in WMS

  • Loading branch information
wonder-sk committed Oct 5, 2016
1 parent 08f4a0f commit 50258e6f01ef7dededbf057c03813ecf3442f5b9
Showing with 16 additions and 3 deletions.
  1. +14 −3 src/providers/wcs/qgswcsprovider.cpp
  2. +2 −0 src/providers/wcs/qgswcsprovider.h
@@ -1663,7 +1663,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 ) )
{
@@ -1677,9 +1688,6 @@ QgsWcsDownloadHandler::QgsWcsDownloadHandler( const QUrl& url, QgsWcsAuthorizati
mCacheReply = QgsNetworkAccessManager::instance()->get( request );
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()
@@ -1689,6 +1697,9 @@ QgsWcsDownloadHandler::~QgsWcsDownloadHandler()

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

mEventLoop->exec( QEventLoop::ExcludeUserInputEvents );

Q_ASSERT( !mCacheReply );
@@ -441,6 +441,8 @@ class QgsWcsDownloadHandler : public QObject
QString mWcsVersion;
QgsError& mCachedError;

QgsRasterBlockFeedback* mFeedback;

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

0 comments on commit 50258e6

Please sign in to comment.
You can’t perform that action at this time.