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 8a47921 commit 7c1131bacd73256afe5ce0090ea2fae3b40c8f93
Showing with 10 additions and 5 deletions.
  1. +10 −5 src/server/qgsserverprojectparser.cpp
@@ -235,6 +235,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 ) );

@@ -274,11 +276,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 );
@@ -288,6 +288,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 7c1131b

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