@@ -651,6 +651,11 @@ bool QgsSymbol::hasDataDefinedProperties() const
651
651
{
652
652
if ( layer->dataDefinedProperties ().hasActiveProperties () )
653
653
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 ;
654
659
}
655
660
return false ;
656
661
}
@@ -708,17 +713,20 @@ void QgsSymbol::renderFeature( const QgsFeature &feature, QgsRenderContext &cont
708
713
ExpressionContextScopePopper scopePopper;
709
714
if ( mSymbolRenderContext ->expressionContextScope () )
710
715
{
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
+ }
722
730
}
723
731
724
732
// Collection of markers to paint, only used for no curve types.
0 commit comments