Set form feature in current_feature variable instead of

... setting the feature member variable
This commit is contained in:
Alessandro Pasotti 2018-05-15 19:17:32 +02:00
parent 55a1984b28
commit 4033cc2ebd

View File

@ -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<QgsFeature>() );
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;
}