Skip to content

Commit 24fb28f

Browse files
committed
Avoid unused expression context updates in more places
1 parent e4ab1a6 commit 24fb28f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/core/symbology/qgssymbol.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,11 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
710710
mSymbolRenderContext->setGeometryPartCount( segmentizedGeometry.constGet()->partCount() );
711711
mSymbolRenderContext->setGeometryPartNum( 1 );
712712

713+
bool needsExpressionContext = hasDataDefinedProperties();
713714
ExpressionContextScopePopper scopePopper;
714715
if ( mSymbolRenderContext->expressionContextScope() )
715716
{
716-
if ( hasDataDefinedProperties() )
717+
if ( needsExpressionContext )
717718
{
718719
// this is somewhat nasty - by appending this scope here it's now owned
719720
// by both mSymbolRenderContext AND context.expressionContext()
@@ -835,7 +836,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
835836
for ( int i = 0; i < mp.numGeometries(); ++i )
836837
{
837838
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 ) );
839841

840842
const QgsPoint &point = static_cast< const QgsPoint & >( *mp.geometryN( i ) );
841843
const QPointF pt = _getPoint( context, point );
@@ -864,7 +866,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
864866
for ( unsigned int i = 0; i < num; ++i )
865867
{
866868
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 ) );
868871

869872
context.setGeometry( geomCollection.geometryN( i ) );
870873
const QgsCurve &curve = dynamic_cast<const QgsCurve &>( *geomCollection.geometryN( i ) );
@@ -922,7 +925,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
922925
{
923926
const unsigned i = listPartIndex[idx];
924927
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 ) );
926930

927931
context.setGeometry( geomCollection.geometryN( i ) );
928932
const QgsPolygon &polygon = dynamic_cast<const QgsPolygon &>( *geomCollection.geometryN( i ) );

0 commit comments

Comments
 (0)