Remove temporary layers (highlight layers and external wms layers)

This commit is contained in:
Marco Hugentobler 2017-10-17 14:53:55 +02:00
parent 40201b2ef5
commit 2dda2abc98
2 changed files with 20 additions and 2 deletions

View File

@ -132,6 +132,11 @@ namespace QgsWms
initNicknameLayers();
}
QgsRenderer::~QgsRenderer()
{
removeTemporaryLayers();
}
QImage *QgsRenderer::getLegendGraphics()
{
@ -2557,6 +2562,7 @@ namespace QgsWms
}
}
mTemporaryLayers.append( highlightLayers );
return highlightLayers;
}
@ -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;
@ -2618,6 +2624,7 @@ namespace QgsWms
if ( externalWMSLayer )
{
layers.append( externalWMSLayer );
mTemporaryLayers.append( externalWMSLayer );
}
}
else if ( mNicknameLayers.contains( nickname ) && !mRestrictedLayers.contains( nickname ) )
@ -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;

View File

@ -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*/
@ -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;
@ -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;
@ -289,6 +293,7 @@ namespace QgsWms
QgsWmsParameters mWmsParameters;
QStringList mRestrictedLayers;
QMap<QString, QgsMapLayer *> mNicknameLayers;
QList<QgsMapLayer *> mTemporaryLayers;
public: