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 93f1246 commit 8815f2e5fe1dd9aea3754b0b8317b7a9219dc938
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/server/qgsserverprojectparser.cpp
@@ -28,6 +28,9 @@
#include "qgseditorwidgetregistry.h"
#include "qgslayertreegroup.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;
}

@@ -1535,7 +1541,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 8815f2e

Please sign in to comment.