Skip to content

Commit

Permalink
[BUGFIX][QGIS Server] To avoid infinite loop in layer creation
Browse files Browse the repository at this point in the history
Insert layer in registry and cache before addValueRelationLayersForLayer
  • Loading branch information
rldhont committed Mar 9, 2016
1 parent ceb86c7 commit 49ce2fa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/server/qgsserverprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );

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

0 comments on commit 49ce2fa

Please sign in to comment.