@@ -753,23 +753,26 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
753
753
deleteSegmentizedGeometry = true ;
754
754
}
755
755
756
- mSymbolRenderContext ->setGeometryPartCount ( segmentizedGeometry->geometry ()->partCount () );
757
- mSymbolRenderContext ->setGeometryPartNum ( 1 );
758
-
759
756
ExpressionContextScopePopper scopePopper;
760
- if ( mSymbolRenderContext -> expressionContextScope () )
757
+ if ( mSymbolRenderContext )
761
758
{
762
- // this is somewhat nasty - by appending this scope here it's now owned
763
- // by both mSymbolRenderContext AND context.expressionContext()
764
- // the RAII scopePopper is required to make sure it always has ownership transferred back
765
- // from context.expressionContext(), even if exceptions of other early exits occur in this
766
- // function
767
- context.expressionContext ().appendScope ( mSymbolRenderContext ->expressionContextScope () );
768
- scopePopper.context = &context.expressionContext ();
759
+ mSymbolRenderContext ->setGeometryPartCount ( segmentizedGeometry->geometry ()->partCount () );
760
+ mSymbolRenderContext ->setGeometryPartNum ( 1 );
769
761
770
- QgsExpressionContextUtils::updateSymbolScope ( this , mSymbolRenderContext ->expressionContextScope () );
771
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_COUNT, mSymbolRenderContext ->geometryPartCount (), true ) );
772
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, 1 , true ) );
762
+ if ( mSymbolRenderContext ->expressionContextScope () )
763
+ {
764
+ // this is somewhat nasty - by appending this scope here it's now owned
765
+ // by both mSymbolRenderContext AND context.expressionContext()
766
+ // the RAII scopePopper is required to make sure it always has ownership transferred back
767
+ // from context.expressionContext(), even if exceptions of other early exits occur in this
768
+ // function
769
+ context.expressionContext ().appendScope ( mSymbolRenderContext ->expressionContextScope () );
770
+ scopePopper.context = &context.expressionContext ();
771
+
772
+ QgsExpressionContextUtils::updateSymbolScope ( this , mSymbolRenderContext ->expressionContextScope () );
773
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_COUNT, mSymbolRenderContext ->geometryPartCount (), true ) );
774
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, 1 , true ) );
775
+ }
773
776
}
774
777
775
778
// Collection of markers to paint, only used for no curve types.
@@ -866,8 +869,11 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
866
869
867
870
for ( int i = 0 ; i < mp->numGeometries (); ++i )
868
871
{
869
- mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
870
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
872
+ if ( mSymbolRenderContext )
873
+ {
874
+ mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
875
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
876
+ }
871
877
872
878
const QgsPointV2* point = static_cast < const QgsPointV2* >( mp->geometryN ( i ) );
873
879
_getPoint ( pt, context, point );
@@ -902,8 +908,11 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
902
908
903
909
for ( unsigned int i = 0 ; i < num && wkbPtr; ++i )
904
910
{
905
- mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
906
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
911
+ if ( mSymbolRenderContext )
912
+ {
913
+ mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
914
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
915
+ }
907
916
908
917
if ( geomCollection )
909
918
{
@@ -952,8 +961,11 @@ void QgsSymbolV2::renderFeature( const QgsFeature& feature, QgsRenderContext& co
952
961
953
962
for ( unsigned int i = 0 ; i < num && wkbPtr; ++i )
954
963
{
955
- mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
956
- mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
964
+ if ( mSymbolRenderContext )
965
+ {
966
+ mSymbolRenderContext ->setGeometryPartNum ( i + 1 );
967
+ mSymbolRenderContext ->expressionContextScope ()->addVariable ( QgsExpressionContextScope::StaticVariable ( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, i + 1 , true ) );
968
+ }
957
969
958
970
if ( geomCollection )
959
971
{
0 commit comments