Skip to content

Commit

Permalink
Cancel WCS requests just like it is done in WMS
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Oct 5, 2016
1 parent 08f4a0f commit 50258e6
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
{
Expand All @@ -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()
Expand All @@ -1689,6 +1697,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
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,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 50258e6

Please sign in to comment.