Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 7c1131b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/server/qgsserverprojectparser.cpp
Expand Up @@ -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 ) );

Expand Down Expand Up @@ -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 );
Expand All @@ -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;
}
Expand Down

0 comments on commit 7c1131b

Please sign in to comment.