Skip to content
Permalink
Browse files

[BUGFIX][QGIS Server] To avoid infinite loop in layer creation

Insert layer in registry and cache before addValueRelationLayersForLayer
  • Loading branch information
rldhont committed Mar 9, 2016
1 parent ceb86c7 commit 49ce2fa38d9d7fb68f657781a62cb6e948689449
Showing with 10 additions and 5 deletions.
  1. +10 −5 src/server/qgsserverprojectparser.cpp
@@ -231,6 +231,8 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&

if ( layer )
{
if ( !QgsMapLayerRegistry::instance()->mapLayer( id ) )
QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );
if ( layer->type() == QgsMapLayer::VectorLayer )
addValueRelationLayersForLayer( dynamic_cast<QgsVectorLayer *>( layer ) );

@@ -270,11 +272,9 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&
layer->readLayerXML( const_cast<QDomElement&>( elem ) ); //should be changed to const in QgsMapLayer
//layer->setLayerName( layerName( elem ) );

if ( layer->type() == QgsMapLayer::VectorLayer )
{
addValueRelationLayersForLayer( dynamic_cast<QgsVectorLayer *>( layer ) );
}

// Insert layer in registry and cache before addValueRelationLayersForLayer
if ( !QgsMapLayerRegistry::instance()->mapLayer( id ) )
QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );
if ( useCache )
{
QgsMSLayerCache::instance()->insertLayer( absoluteUri, id, layer, mProjectPath );
@@ -284,6 +284,11 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&
//todo: fixme
//mLayersToRemove.push_back( layer );
}

if ( layer->type() == QgsMapLayer::VectorLayer )
{
addValueRelationLayersForLayer( dynamic_cast<QgsVectorLayer *>( layer ) );
}
}
return layer;
}

0 comments on commit 49ce2fa

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