Skip to content

Commit

Permalink
[wms] if a previous request to fetch the legend failed, don't bother …
Browse files Browse the repository at this point in the history
…trying

to fetch it again!

Otherwise misconfigured services which return flawed images will just keep retrying to
fetch on every map extent change operation...
  • Loading branch information
nyalldawson committed Aug 10, 2020
1 parent a6a14df commit d72e226
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -3790,6 +3790,14 @@ QImage QgsWmsProvider::getLegendGraphic( double scale, bool forceRefresh, const

QgsImageFetcher *QgsWmsProvider::getLegendGraphicFetcher( const QgsMapSettings *mapSettings )
{
if ( mLegendGraphicFetchErrored && !mSettings.mEnableContextualLegend )
{
// if a previous request to fetch the legend failed, don't bother trying to fetch it again!
// Otherwise misconfigured services which return flawed images will just keep retrying to
// fetch on every map extent change operation...
return nullptr;
}

double scale;
QgsRectangle mapExtent;
if ( mapSettings && mSettings.mEnableContextualLegend )
Expand Down Expand Up @@ -3836,6 +3844,10 @@ QgsImageFetcher *QgsWmsProvider::getLegendGraphicFetcher( const QgsMapSettings *
fetcher->setProperty( "legendScale", QVariant::fromValue( scale ) );
fetcher->setProperty( "legendExtent", QVariant::fromValue( mapExtent.toRectF() ) );
connect( fetcher, &QgsImageFetcher::finish, this, &QgsWmsProvider::getLegendGraphicReplyFinished );
connect( fetcher, &QgsImageFetcher::error, this, [ = ]( const QString & )
{
mLegendGraphicFetchErrored = true;
} );
return fetcher;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/providers/wms/qgswmsprovider.h
Expand Up @@ -416,6 +416,9 @@ class QgsWmsProvider final: public QgsRasterDataProvider

std::unique_ptr<QgsImageFetcher> mLegendGraphicFetcher;

//! TRUE if an error was encountered while fetching a legend graphic
bool mLegendGraphicFetchErrored = false;

/**
* Visibility status of the given active sublayer
*/
Expand Down

0 comments on commit d72e226

Please sign in to comment.