From 795e2477cb61eac7f485c32bbcd5a2205a89acef Mon Sep 17 00:00:00 2001 From: Matthias Kuhn Date: Fri, 7 Jul 2017 11:42:39 +0200 Subject: [PATCH] Fix running expressions without context --- src/core/expression/qgsexpressionfunction.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/expression/qgsexpressionfunction.cpp b/src/core/expression/qgsexpressionfunction.cpp index 1efad41b5548..a515d5ebbc34 100644 --- a/src/core/expression/qgsexpressionfunction.cpp +++ b/src/core/expression/qgsexpressionfunction.cpp @@ -4313,7 +4313,7 @@ bool QgsWithVariableExpressionFunction::isStatic( const QgsExpressionNodeFunctio QgsExpressionContext *updatedContext = const_cast( context ); updatedContext->appendScope( scope ); - if ( args->at( 3 )->isStatic( parent, updatedContext ) ) + if ( args->at( 2 )->isStatic( parent, updatedContext ) ) isStatic = true; updatedContext->popScope(); } @@ -4336,9 +4336,13 @@ QVariant QgsWithVariableExpressionFunction::run( QgsExpressionNode::NodeList *ar scope->setVariable( name.toString(), value ); QgsExpressionContext *updatedContext = const_cast( context ); + if ( !context ) + updatedContext = new QgsExpressionContext(); updatedContext->appendScope( scope ); result = args->at( 2 )->eval( parent, updatedContext ); delete updatedContext->popScope(); + if ( !context ) + delete updatedContext; return result; }