@@ -710,10 +710,11 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
710
710
mSymbolRenderContext ->setGeometryPartCount ( segmentizedGeometry.constGet ()->partCount () );
711
711
mSymbolRenderContext ->setGeometryPartNum ( 1 );
712
712
713
+ bool needsExpressionContext = hasDataDefinedProperties ();
713
714
ExpressionContextScopePopper scopePopper;
714
715
if ( mSymbolRenderContext ->expressionContextScope () )
715
716
{
716
- if ( hasDataDefinedProperties () )
717
+ if ( needsExpressionContext )
717
718
{
718
719
// this is somewhat nasty - by appending this scope here it's now owned
719
720
// by both mSymbolRenderContext AND context.expressionContext()
@@ -835,7 +836,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
835
836
for ( int i = 0 ; i < mp.numGeometries (); ++i )
836
837
{
837
838
mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
838
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
839
+ if ( needsExpressionContext )
840
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
839
841
840
842
const QgsPoint &point = static_cast < const QgsPoint & >( *mp.geometryN ( i ) );
841
843
const QPointF pt = _getPoint ( context, point );
@@ -864,7 +866,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
864
866
for ( unsigned int i = 0 ; i < num; ++i )
865
867
{
866
868
mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
867
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
869
+ if ( needsExpressionContext )
870
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
868
871
869
872
context.setGeometry ( geomCollection.geometryN ( i ) );
870
873
const QgsCurve &curve = dynamic_cast <const QgsCurve &>( *geomCollection.geometryN ( i ) );
@@ -922,7 +925,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
922
925
{
923
926
const unsigned i = listPartIndex[idx];
924
927
mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
925
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
928
+ if ( needsExpressionContext )
929
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
926
930
927
931
context.setGeometry ( geomCollection.geometryN ( i ) );
928
932
const QgsPolygon &polygon = dynamic_cast <const QgsPolygon &>( *geomCollection.geometryN ( i ) );
0 commit comments