Skip to content

Commit

Permalink
Fix running expressions without context
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jul 7, 2017
1 parent 30f86e6 commit 795e247
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/expression/qgsexpressionfunction.cpp
Expand Up @@ -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();
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 795e247

Please sign in to comment.