Skip to content
Permalink
Browse files

Avoid unused expression context updates in more places

  • Loading branch information
nyalldawson committed Feb 11, 2018
1 parent e4ab1a6 commit 24fb28f7bb7963153fe3e25b176676bb578a3766
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/core/symbology/qgssymbol.cpp
@@ -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()
@@ -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 );
@@ -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 ) );
@@ -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 ) );

0 comments on commit 24fb28f

Please sign in to comment.
You can’t perform that action at this time.