From 4033cc2ebd411767adacfc61946c6294aa7a8519 Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Tue, 15 May 2018 19:17:32 +0200 Subject: [PATCH] Set form feature in current_feature variable instead of ... setting the feature member variable --- src/core/qgsexpressioncontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/qgsexpressioncontext.cpp b/src/core/qgsexpressioncontext.cpp index d5787c8102b..37fca724a09 100644 --- a/src/core/qgsexpressioncontext.cpp +++ b/src/core/qgsexpressioncontext.cpp @@ -747,7 +747,7 @@ class GetCurrentFormFieldValue : public QgsScopedExpressionFunction QVariant func( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *, const QgsExpressionNodeFunction * ) override { QString fieldName( values.at( 0 ).toString() ); - const QgsFeature feat( context->feature() ); + const QgsFeature feat( context->variable( QStringLiteral( "current_feature" ) ).value() ); if ( fieldName.isEmpty() || ! feat.isValid( ) ) { return QVariant(); @@ -793,9 +793,9 @@ class GetProcessingParameterValue : public QgsScopedExpressionFunction QgsExpressionContextScope *QgsExpressionContextUtils::formScope( const QgsFeature &formFeature ) { QgsExpressionContextScope *scope = new QgsExpressionContextScope( QObject::tr( "Form" ) ); - scope->setFeature( formFeature ); scope->addFunction( QStringLiteral( "current_value" ), new GetCurrentFormFieldValue( ) ); scope->setVariable( QStringLiteral( "current_geometry" ), formFeature.geometry( ), true ); + scope->setVariable( QStringLiteral( "current_feature" ), formFeature, true ); return scope; }