Skip to content
Permalink
Browse files
[BUGFIX][QGIS Server] Joins was not reloaded if the layer is in cache
With the commit f6aad8b, the QgsMapLayerRegistry signal `layersWillBeRemoved` is always emit. This imply that the vector layer join buffer is empty and not reloaded if the layer is in cache.

To fix it, the layer XML element has to be read each time the layer is used.

This commit fixed #15522 Qgis Server doesnt' respect the styling from Desktop
  • Loading branch information
rldhont committed Oct 7, 2016
1 parent f971b0d commit 1df9d7e1a60b3e6c913fae1414a6b397a1dc6aae
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/server/qgsserverprojectparser.cpp
@@ -28,6 +28,9 @@
#include "qgslayertreegroup.h"
#include "qgslogger.h"

#include "qgslogger.h"
#include "qgsmessagelog.h"

#include <QDomDocument>
#include <QFileInfo>
#include <QStringList>
@@ -234,8 +237,11 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement&
if ( !QgsMapLayerRegistry::instance()->mapLayer( id ) )
QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );
if ( layer->type() == QgsMapLayer::VectorLayer )
{
addValueRelationLayersForLayer( dynamic_cast<QgsVectorLayer *>( layer ) );

// Reload joins and expression fields
layer->readLayerXML( const_cast<QDomElement&>( elem ) );
}
return layer;
}

@@ -1541,7 +1547,7 @@ void QgsServerProjectParser::addJoinLayersForElement( const QDomElement& layerEl
{
QString id = joinNodeList.at( i ).toElement().attribute( "joinLayerId" );
QgsMapLayer* layer = mapLayerFromLayerId( id );
if ( layer )
if ( layer && !QgsMapLayerRegistry::instance()->mapLayer( id ))
{
QgsMapLayerRegistry::instance()->addMapLayer( layer, false, false );
}

0 comments on commit 1df9d7e

Please sign in to comment.