Deprecate vector layer setter/getter within QgsSymbol

It's not used, and potentially very dangerous
This commit is contained in:
Nyall Dawson 2018-08-31 11:22:58 +10:00
parent e63fedfa36
commit 5e1d1a4c8c
4 changed files with 46 additions and 6 deletions

View File

@ -387,14 +387,21 @@ Returns whether the symbol utilizes any data defined properties.
.. versionadded:: 2.12
%End
void setLayer( const QgsVectorLayer *layer );
void setLayer( const QgsVectorLayer *layer ) /Deprecated/;
%Docstring
.. note::
the layer will be NULL after stopRender
.. deprecated:: Will be removed in QGIS 4.0
%End
const QgsVectorLayer *layer() const /Deprecated/;
%Docstring
.. deprecated:: Will be removed in QGIS 4.0
%End
const QgsVectorLayer *layer() const;
void renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false, int currentVertexMarkerType = 0, int currentVertexMarkerSize = 0 );
%Docstring

View File

@ -78,6 +78,7 @@ QgsProperty scaleWholeSymbol( double scaleFactorX, double scaleFactorY, const Qg
////////////////////
Q_NOWARN_DEPRECATED_PUSH // because of deprecated mLayer
QgsSymbol::QgsSymbol( SymbolType type, const QgsSymbolLayerList &layers )
: mType( type )
, mLayers( layers )
@ -97,6 +98,7 @@ QgsSymbol::QgsSymbol( SymbolType type, const QgsSymbolLayerList &layers )
}
}
}
Q_NOWARN_DEPRECATED_POP
QPolygonF QgsSymbol::_getLineString( QgsRenderContext &context, const QgsCurve &curve, bool clipToExtent )
{
@ -434,7 +436,9 @@ void QgsSymbol::stopRender( QgsRenderContext &context )
mSymbolRenderContext.reset( nullptr );
Q_NOWARN_DEPRECATED_PUSH
mLayer = nullptr;
Q_NOWARN_DEPRECATED_POP
}
void QgsSymbol::setColor( const QColor &color )
@ -669,6 +673,20 @@ bool QgsSymbol::hasDataDefinedProperties() const
return false;
}
void QgsSymbol::setLayer( const QgsVectorLayer *layer )
{
Q_NOWARN_DEPRECATED_PUSH
mLayer = layer;
Q_NOWARN_DEPRECATED_POP
}
const QgsVectorLayer *QgsSymbol::layer() const
{
Q_NOWARN_DEPRECATED_PUSH
return mLayer;
Q_NOWARN_DEPRECATED_POP
}
///@cond PRIVATE
/**
@ -1554,7 +1572,9 @@ QgsMarkerSymbol *QgsMarkerSymbol::clone() const
{
QgsMarkerSymbol *cloneSymbol = new QgsMarkerSymbol( cloneLayers() );
cloneSymbol->setOpacity( mOpacity );
Q_NOWARN_DEPRECATED_PUSH
cloneSymbol->setLayer( mLayer );
Q_NOWARN_DEPRECATED_POP
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
return cloneSymbol;
}
@ -1771,7 +1791,9 @@ QgsLineSymbol *QgsLineSymbol::clone() const
{
QgsLineSymbol *cloneSymbol = new QgsLineSymbol( cloneLayers() );
cloneSymbol->setOpacity( mOpacity );
Q_NOWARN_DEPRECATED_PUSH
cloneSymbol->setLayer( mLayer );
Q_NOWARN_DEPRECATED_POP
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
return cloneSymbol;
}
@ -1889,7 +1911,9 @@ QgsFillSymbol *QgsFillSymbol::clone() const
{
QgsFillSymbol *cloneSymbol = new QgsFillSymbol( cloneLayers() );
cloneSymbol->setOpacity( mOpacity );
Q_NOWARN_DEPRECATED_PUSH
cloneSymbol->setLayer( mLayer );
Q_NOWARN_DEPRECATED_POP
cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent );
return cloneSymbol;
}

View File

@ -394,9 +394,16 @@ class CORE_EXPORT QgsSymbol
*/
bool hasDataDefinedProperties() const;
//! \note the layer will be NULL after stopRender
void setLayer( const QgsVectorLayer *layer ) { mLayer = layer; }
const QgsVectorLayer *layer() const { return mLayer; }
/**
* \note the layer will be NULL after stopRender
* \deprecated Will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED void setLayer( const QgsVectorLayer *layer ) SIP_DEPRECATED;
/**
* \deprecated Will be removed in QGIS 4.0
*/
Q_DECL_DEPRECATED const QgsVectorLayer *layer() const SIP_DEPRECATED;
/**
* Render a feature. Before calling this the startRender() method should be called to initialize
@ -483,7 +490,7 @@ class CORE_EXPORT QgsSymbol
RenderHints mRenderHints = nullptr;
bool mClipFeaturesToExtent = true;
const QgsVectorLayer *mLayer = nullptr; //current vectorlayer
Q_DECL_DEPRECATED const QgsVectorLayer *mLayer = nullptr; //current vectorlayer
private:
#ifdef SIP_RUN

View File

@ -472,7 +472,9 @@ void QgsSymbolSelectorWidget::layerChanged()
{
mDataDefineRestorer.reset();
// then it must be a symbol
Q_NOWARN_DEPRECATED_PUSH
currentItem->symbol()->setLayer( mVectorLayer );
Q_NOWARN_DEPRECATED_POP
// Now populate symbols of that type using the symbols list widget:
QgsSymbolsListWidget *symbolsList = new QgsSymbolsListWidget( currentItem->symbol(), mStyle, mAdvancedMenu, this, mVectorLayer );
symbolsList->setContext( mContext );