Skip to content
Permalink
Browse files

Fix running expressions without context

  • Loading branch information
m-kuhn committed Jul 7, 2017
1 parent 30f86e6 commit 795e2477cb61eac7f485c32bbcd5a2205a89acef
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/core/expression/qgsexpressionfunction.cpp
@@ -4313,7 +4313,7 @@ bool QgsWithVariableExpressionFunction::isStatic( const QgsExpressionNodeFunctio
QgsExpressionContext *updatedContext = const_cast<QgsExpressionContext *>( 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<QgsExpressionContext *>( 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;
}

0 comments on commit 795e247

Please sign in to comment.
You can’t perform that action at this time.