Skip to content

Commit

Permalink
More gui expression porting
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 22, 2015
1 parent 786de4b commit 000a62f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/qgsdiagramproperties.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -526,14 +526,20 @@ void QgsDiagramProperties::on_mFindMaximumValueButton_clicked()
if ( isExpression ) if ( isExpression )
{ {
QgsExpression exp( sizeFieldNameOrExp ); QgsExpression exp( sizeFieldNameOrExp );
exp.prepare( mLayer->fields() ); QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayer );

exp.prepare( &context );
if ( !exp.hasEvalError() ) if ( !exp.hasEvalError() )
{ {
QgsFeature feature; QgsFeature feature;
QgsFeatureIterator features = mLayer->getFeatures(); QgsFeatureIterator features = mLayer->getFeatures();
while ( features.nextFeature( *&feature ) ) while ( features.nextFeature( *&feature ) )
{ {
maxValue = qMax( maxValue, exp.evaluate( &feature ).toFloat() ); context.setFeature( feature );
maxValue = qMax( maxValue, exp.evaluate( &context ).toFloat() );
} }
} }
else else
Expand Down

0 comments on commit 000a62f

Please sign in to comment.