Skip to content
Permalink
Browse files

Properly handle non matching number of WMS styles and layers in WMS p…

…rovider (inspired by PR #2001)

(cherry picked from commit bcb9513)
  • Loading branch information
jef-n committed Apr 26, 2015
1 parent a64ef9f commit 96c3d92768e782d3b556735fee84073a02def7dd
Showing with 7 additions and 5 deletions.
  1. +6 −4 src/providers/wms/qgswmsprovider.cpp
  2. +1 −1 src/providers/wms/qgswmsprovider.h
@@ -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 )
@@ -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
@@ -290,6 +290,8 @@ void QgsWmsProvider::addLayers()
mTileLayer = 0;

QgsDebugMsg( "Exiting." );

return true;
}

void QgsWmsProvider::setConnectionName( QString const &connName )
@@ -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

0 comments on commit 96c3d92

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