Skip to content

Commit

Permalink
Set missing expression context in some filters
Browse files Browse the repository at this point in the history
In some filters the expression context was not set, so that references to
variables would only work in the preview, but not when actually using them.
  • Loading branch information
dgoedkoop authored and nyalldawson committed Jan 21, 2018
1 parent 9451f2e commit fcbf4cb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/composer/qgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ int QgsAtlasComposition::updateFeatures()
// select all features with all attributes
QgsFeatureRequest req;

req.setExpressionContext( expressionContext );

std::unique_ptr<QgsExpression> filterExpression;
if ( mFilterFeatures && !mFeatureFilter.isEmpty() )
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ QgsValueRelationFieldFormatter::ValueRelationCache QgsValueRelationFieldFormatte
request.setSubsetOfAttributes( QgsAttributeList() << ki << vi );
if ( !config.value( QStringLiteral( "FilterExpression" ) ).toString().isEmpty() )
{
QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( layer ) );
request.setExpressionContext( context );
request.setFilterExpression( config.value( QStringLiteral( "FilterExpression" ) ).toString() );
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/layout/qgslayoutatlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ int QgsLayoutAtlas::updateFeatures()
// select all features with all attributes
QgsFeatureRequest req;

req.setExpressionContext( expressionContext );

mFilterParserError.clear();
if ( mFilterFeatures && !mFilterExpression.isEmpty() )
{
Expand Down

0 comments on commit fcbf4cb

Please sign in to comment.