Skip to content

Commit 795e247

Browse files
committed
Fix running expressions without context
1 parent 30f86e6 commit 795e247

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/expression/qgsexpressionfunction.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4313,7 +4313,7 @@ bool QgsWithVariableExpressionFunction::isStatic( const QgsExpressionNodeFunctio
43134313
QgsExpressionContext *updatedContext = const_cast<QgsExpressionContext *>( context );
43144314
updatedContext->appendScope( scope );
43154315

4316-
if ( args->at( 3 )->isStatic( parent, updatedContext ) )
4316+
if ( args->at( 2 )->isStatic( parent, updatedContext ) )
43174317
isStatic = true;
43184318
updatedContext->popScope();
43194319
}
@@ -4336,9 +4336,13 @@ QVariant QgsWithVariableExpressionFunction::run( QgsExpressionNode::NodeList *ar
43364336
scope->setVariable( name.toString(), value );
43374337

43384338
QgsExpressionContext *updatedContext = const_cast<QgsExpressionContext *>( context );
4339+
if ( !context )
4340+
updatedContext = new QgsExpressionContext();
43394341
updatedContext->appendScope( scope );
43404342
result = args->at( 2 )->eval( parent, updatedContext );
43414343
delete updatedContext->popScope();
4344+
if ( !context )
4345+
delete updatedContext;
43424346

43434347
return result;
43444348
}

0 commit comments

Comments
 (0)