Skip to content

Commit e4ab1a6

Browse files
committedFeb 11, 2018
Don't generate symbol expression context scope when it's not
being used Refs #17809
1 parent 180d878 commit e4ab1a6

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed
 

‎src/core/symbology/qgssymbol.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,11 @@ bool QgsSymbol::hasDataDefinedProperties() const
651651
{
652652
if ( layer->dataDefinedProperties().hasActiveProperties() )
653653
return true;
654+
// we treat geometry generator layers like they have data defined properties,
655+
// since the WHOLE layer is based on expressions and requires the full expression
656+
// context
657+
if ( layer->layerType() == QLatin1String( "GeometryGenerator" ) )
658+
return true;
654659
}
655660
return false;
656661
}
@@ -708,17 +713,20 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
708713
ExpressionContextScopePopper scopePopper;
709714
if ( mSymbolRenderContext->expressionContextScope() )
710715
{
711-
// this is somewhat nasty - by appending this scope here it's now owned
712-
// by both mSymbolRenderContext AND context.expressionContext()
713-
// the RAII scopePopper is required to make sure it always has ownership transferred back
714-
// from context.expressionContext(), even if exceptions of other early exits occur in this
715-
// function
716-
context.expressionContext().appendScope( mSymbolRenderContext->expressionContextScope() );
717-
scopePopper.context = &context.expressionContext();
718-
719-
QgsExpressionContextUtils::updateSymbolScope( this, mSymbolRenderContext->expressionContextScope() );
720-
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_COUNT, mSymbolRenderContext->geometryPartCount(), true ) );
721-
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, 1, true ) );
716+
if ( hasDataDefinedProperties() )
717+
{
718+
// this is somewhat nasty - by appending this scope here it's now owned
719+
// by both mSymbolRenderContext AND context.expressionContext()
720+
// the RAII scopePopper is required to make sure it always has ownership transferred back
721+
// from context.expressionContext(), even if exceptions of other early exits occur in this
722+
// function
723+
context.expressionContext().appendScope( mSymbolRenderContext->expressionContextScope() );
724+
scopePopper.context = &context.expressionContext();
725+
726+
QgsExpressionContextUtils::updateSymbolScope( this, mSymbolRenderContext->expressionContextScope() );
727+
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_COUNT, mSymbolRenderContext->geometryPartCount(), true ) );
728+
mSymbolRenderContext->expressionContextScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, 1, true ) );
729+
}
722730
}
723731

724732
// Collection of markers to paint, only used for no curve types.

0 commit comments

Comments
 (0)
Please sign in to comment.