Skip to content
Permalink
Browse files

[BUGFIX][QGIS Server] Do not cache invalid layer

After readLayerXml, the server stored layers in cache and in registry without verifying validity.
  • Loading branch information
rldhont committed Oct 25, 2016
1 parent 009c0ea commit 80827625dfa9616a9c99e4645463b6e248ed95b2
Showing with 5 additions and 1 deletion.
  1. +1 −1 src/server/qgshostedrdsbuilder.cpp
  2. +4 −0 src/server/qgsserverprojectparser.cpp
@@ -62,7 +62,7 @@ QgsMapLayer* QgsHostedRDSBuilder::createMapLayer( const QDomElement& elem,
{
rl = qobject_cast<QgsRasterLayer*>( QgsMSLayerCache::instance()->searchLayer( uri, layerName ) );
}
if ( !rl )
if ( !rl || !rl->isValid() )
{
QgsDebugMsg( "hostedrds layer not in cache, so create and insert it" );
rl = new QgsRasterLayer( uri, layerNameFromUri( uri ) );
@@ -278,6 +278,10 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&
layer->readLayerXML( const_cast<QDomElement&>( elem ) ); //should be changed to const in QgsMapLayer
//layer->setLayerName( layerName( elem ) );

if ( !layer->isValid() )
{
return nullptr;
}
// Insert layer in registry and cache before addValueRelationLayersForLayer
if ( !QgsMapLayerRegistry::instance()->mapLayer( id ) )
QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );

0 comments on commit 8082762

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