Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Properly handle non matching number of WMS styles and layers in WMS p…
…rovider (inspired by PR #2001)
  • Loading branch information
jef-n committed Apr 22, 2015
1 parent 32cc6e0 commit bcb9513
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -123,7 +123,8 @@ QgsWmsProvider::QgsWmsProvider( QString const& uri, const QgsWmsCapabilities* ca
return;
}

addLayers();
if ( !addLayers() )
return;

// if there are already parsed capabilities, use them!
if ( capabilities )
Expand Down Expand Up @@ -265,15 +266,14 @@ QString QgsWmsProvider::getLegendGraphicUrl() const
return url.isEmpty() ? url : prepareUri( url );
}

void QgsWmsProvider::addLayers()
bool QgsWmsProvider::addLayers()
{
QgsDebugMsg( "Entering: layers:" + mSettings.mActiveSubLayers.join( ", " ) + ", styles:" + mSettings.mActiveSubStyles.join( ", " ) );

if ( mSettings.mActiveSubLayers.size() != mSettings.mActiveSubStyles.size() )
{
QgsMessageLog::logMessage( tr( "Number of layers and styles don't match" ), tr( "WMS" ) );
mValid = false;
return;
return false;
}

// Set the visibility of these new layers on by default
Expand All @@ -290,6 +290,8 @@ void QgsWmsProvider::addLayers()
mTileLayer = 0;

QgsDebugMsg( "Exiting." );

return true;
}

void QgsWmsProvider::setConnectionName( QString const &connName )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wms/qgswmsprovider.h
Expand Up @@ -385,7 +385,7 @@ class QgsWmsProvider : public QgsRasterDataProvider
/**
* Add the list of WMS layer names to be rendered by this server
*/
void addLayers();
bool addLayers();

/**
* Set the image projection (in WMS CRS format) used in the transfer from the WMS server
Expand Down

0 comments on commit bcb9513

Please sign in to comment.