Skip to content

Commit

Permalink
Avoid unused expression context updates in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 11, 2018
1 parent e4ab1a6 commit 24fb28f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -710,10 +710,11 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
mSymbolRenderContext->setGeometryPartCount( segmentizedGeometry.constGet()->partCount() );
mSymbolRenderContext->setGeometryPartNum( 1 );

bool needsExpressionContext = hasDataDefinedProperties();
ExpressionContextScopePopper scopePopper;
if ( mSymbolRenderContext->expressionContextScope() )
{
if ( hasDataDefinedProperties() )
if ( needsExpressionContext )
{
// this is somewhat nasty - by appending this scope here it's now owned
// by both mSymbolRenderContext AND context.expressionContext()
Expand Down Expand Up @@ -835,7 +836,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
for ( int i = 0; i < mp.numGeometries(); ++i )
{
mSymbolRenderContext->setGeometryPartNum( i + 1 );
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1, true ) );
if ( needsExpressionContext )
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1, true ) );

const QgsPoint &point = static_cast< const QgsPoint & >( *mp.geometryN( i ) );
const QPointF pt = _getPoint( context, point );
Expand Down Expand Up @@ -864,7 +866,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
for ( unsigned int i = 0; i < num; ++i )
{
mSymbolRenderContext->setGeometryPartNum( i + 1 );
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1, true ) );
if ( needsExpressionContext )
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1, true ) );

context.setGeometry( geomCollection.geometryN( i ) );
const QgsCurve &curve = dynamic_cast<const QgsCurve &>( *geomCollection.geometryN( i ) );
Expand Down Expand Up @@ -922,7 +925,8 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
{
const unsigned i = listPartIndex[idx];
mSymbolRenderContext->setGeometryPartNum( i + 1 );
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1, true ) );
if ( needsExpressionContext )
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1, true ) );

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

0 comments on commit 24fb28f

Please sign in to comment.