Skip to content

Commit

Permalink
[BUGFIX][QGIS Server] Joins was not reloaded if the layer is in cache
Browse files Browse the repository at this point in the history
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 1df9d7e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/server/qgsserverprojectparser.cpp
Expand Up @@ -28,6 +28,9 @@
#include "qgslayertreegroup.h"
#include "qgslogger.h"

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

#include <QDomDocument>
#include <QFileInfo>
#include <QStringList>
Expand Down Expand Up @@ -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;
}

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

0 comments on commit 1df9d7e

Please sign in to comment.