mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-10 00:13:55 -04:00
[BUGFIX][QGIS Server] Do not cache invalid layer
After readLayerXml, the server stored layers in cache and in registry without verifying validity.
This commit is contained in:
parent
a43f8a3616
commit
9d0bb34010
@ -61,7 +61,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 ) );
|
||||
|
@ -280,6 +280,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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user