Skip to content

Commit

Permalink
Remove temporary layers (highlight layers and external wms layers)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Oct 17, 2017
1 parent 40201b2 commit 2dda2ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/server/services/wms/qgswmsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ namespace QgsWms
initNicknameLayers();
}

QgsRenderer::~QgsRenderer()
{
removeTemporaryLayers();
}


QImage *QgsRenderer::getLegendGraphics()
{
Expand Down Expand Up @@ -2557,6 +2562,7 @@ namespace QgsWms
}
}

mTemporaryLayers.append( highlightLayers );
return highlightLayers;
}

Expand Down Expand Up @@ -2602,7 +2608,7 @@ namespace QgsWms
return layers;
}

QList<QgsMapLayer *> QgsRenderer::stylizedLayers( const QList<QgsWmsParametersLayer> &params ) const
QList<QgsMapLayer *> QgsRenderer::stylizedLayers( const QList<QgsWmsParametersLayer> &params )
{
QList<QgsMapLayer *> layers;

Expand All @@ -2618,6 +2624,7 @@ namespace QgsWms
if ( externalWMSLayer )
{
layers.append( externalWMSLayer );
mTemporaryLayers.append( externalWMSLayer );
}
}
else if ( mNicknameLayers.contains( nickname ) && !mRestrictedLayers.contains( nickname ) )
Expand Down Expand Up @@ -2672,6 +2679,12 @@ namespace QgsWms
return wmsLayer;
}

void QgsRenderer::removeTemporaryLayers()
{
qDeleteAll( mTemporaryLayers );
mTemporaryLayers.clear();
}

QPainter *QgsRenderer::layersRendering( const QgsMapSettings &mapSettings, QImage &image, HitTest *hitTest ) const
{
QPainter *painter = nullptr;
Expand Down
7 changes: 6 additions & 1 deletion src/server/services/wms/qgswmsrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ namespace QgsWms
const QgsProject *project,
const QgsServerRequest::Parameters &parameters );

~QgsRenderer();

/**
* Returns the map legend as an image (or a null pointer in case of error). The caller takes ownership
of the image object*/
Expand Down Expand Up @@ -154,7 +156,7 @@ namespace QgsWms
void annotationsRendering( QPainter *painter ) const;

// Return a list of layers stylized with LAYERS/STYLES parameters
QList<QgsMapLayer *> stylizedLayers( const QList<QgsWmsParametersLayer> &params ) const;
QList<QgsMapLayer *> stylizedLayers( const QList<QgsWmsParametersLayer> &params );

// Return a list of layers stylized with SLD parameter
QList<QgsMapLayer *> sldStylizedLayers( const QString &sld ) const;
Expand Down Expand Up @@ -277,6 +279,8 @@ namespace QgsWms
//! Creates external WMS layer. Caller takes ownership
QgsMapLayer *createExternalWMSLayer( const QString &externalLayerId ) const;

void removeTemporaryLayers();

private:

const QgsServerRequest::Parameters &mParameters;
Expand All @@ -289,6 +293,7 @@ namespace QgsWms
QgsWmsParameters mWmsParameters;
QStringList mRestrictedLayers;
QMap<QString, QgsMapLayer *> mNicknameLayers;
QList<QgsMapLayer *> mTemporaryLayers;

public:

Expand Down

0 comments on commit 2dda2ab

Please sign in to comment.