@@ -83,7 +83,6 @@ QgsSymbol::QgsSymbol( SymbolType type, const QgsSymbolLayerList &layers )
83
83
, mRenderHints( 0 )
84
84
, mClipFeaturesToExtent( true )
85
85
, mLayer( nullptr )
86
- , mSymbolRenderContext( nullptr )
87
86
{
88
87
89
88
// check they're all correct symbol layers
@@ -188,7 +187,6 @@ void QgsSymbol::_getPolygon( QPolygonF &pts, QList<QPolygonF> &holes, QgsRenderC
188
187
189
188
QgsSymbol::~QgsSymbol ()
190
189
{
191
- delete mSymbolRenderContext ;
192
190
// delete all symbol layers (we own them, so it's okay)
193
191
qDeleteAll ( mLayers );
194
192
}
@@ -377,14 +375,12 @@ bool QgsSymbol::changeSymbolLayer( int index, QgsSymbolLayer *layer )
377
375
378
376
void QgsSymbol::startRender ( QgsRenderContext &context, const QgsFields &fields )
379
377
{
380
- delete mSymbolRenderContext ;
381
- mSymbolRenderContext = new QgsSymbolRenderContext ( context, outputUnit (), mAlpha , false , mRenderHints , nullptr , fields, mapUnitScale () );
378
+ mSymbolRenderContext .reset ( new QgsSymbolRenderContext ( context, outputUnit (), mAlpha , false , mRenderHints , nullptr , fields, mapUnitScale () ) );
382
379
383
380
QgsSymbolRenderContext symbolContext ( context, outputUnit (), mAlpha , false , mRenderHints , nullptr , fields, mapUnitScale () );
384
381
385
- QgsExpressionContextScope *scope = QgsExpressionContextUtils::updateSymbolScope ( this , new QgsExpressionContextScope () );
386
-
387
- mSymbolRenderContext ->setExpressionContextScope ( scope );
382
+ std::unique_ptr< QgsExpressionContextScope > scope ( QgsExpressionContextUtils::updateSymbolScope ( this , new QgsExpressionContextScope () ) );
383
+ mSymbolRenderContext ->setExpressionContextScope ( scope.release () );
388
384
389
385
Q_FOREACH ( QgsSymbolLayer *layer, mLayers )
390
386
{
@@ -410,8 +406,7 @@ void QgsSymbol::stopRender( QgsRenderContext &context )
410
406
}
411
407
}
412
408
413
- delete mSymbolRenderContext ;
414
- mSymbolRenderContext = nullptr ;
409
+ mSymbolRenderContext .reset ( nullptr );
415
410
416
411
mLayer = nullptr ;
417
412
}
@@ -985,7 +980,7 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
985
980
986
981
QgsSymbolRenderContext *QgsSymbol::symbolRenderContext ()
987
982
{
988
- return mSymbolRenderContext ;
983
+ return mSymbolRenderContext . get () ;
989
984
}
990
985
991
986
void QgsSymbol::renderVertexMarker ( QPointF pt, QgsRenderContext &context, int currentVertexMarkerType, int currentVertexMarkerSize )
@@ -998,7 +993,6 @@ void QgsSymbol::renderVertexMarker( QPointF pt, QgsRenderContext &context, int c
998
993
999
994
QgsSymbolRenderContext::QgsSymbolRenderContext ( QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal alpha, bool selected, QgsSymbol::RenderHints renderHints, const QgsFeature *f, const QgsFields &fields, const QgsMapUnitScale &mapUnitScale )
1000
995
: mRenderContext( c )
1001
- , mExpressionContextScope( nullptr )
1002
996
, mOutputUnit( u )
1003
997
, mMapUnitScale( mapUnitScale )
1004
998
, mAlpha( alpha )
@@ -1011,11 +1005,6 @@ QgsSymbolRenderContext::QgsSymbolRenderContext( QgsRenderContext &c, QgsUnitType
1011
1005
{
1012
1006
}
1013
1007
1014
- QgsSymbolRenderContext::~QgsSymbolRenderContext ()
1015
- {
1016
- delete mExpressionContextScope ;
1017
- }
1018
-
1019
1008
void QgsSymbolRenderContext::setOriginalValueVariable ( const QVariant &value )
1020
1009
{
1021
1010
mRenderContext .expressionContext ().setOriginalValueVariable ( value );
@@ -1043,12 +1032,12 @@ QgsSymbolRenderContext &QgsSymbolRenderContext::operator=( const QgsSymbolRender
1043
1032
1044
1033
QgsExpressionContextScope *QgsSymbolRenderContext::expressionContextScope ()
1045
1034
{
1046
- return mExpressionContextScope ;
1035
+ return mExpressionContextScope . get () ;
1047
1036
}
1048
1037
1049
1038
void QgsSymbolRenderContext::setExpressionContextScope ( QgsExpressionContextScope *contextScope )
1050
1039
{
1051
- mExpressionContextScope = contextScope;
1040
+ mExpressionContextScope . reset ( contextScope ) ;
1052
1041
}
1053
1042
1054
1043
// /////////////////
0 commit comments