expression: validate places value of format_number (fixes #12796)

This commit is contained in:
Juergen E. Fischer 2015-06-01 20:19:49 +02:00
parent 239dc71d43
commit 518072e9b3

View File

@ -1345,6 +1345,11 @@ static QVariant fcnFormatNumber( const QVariantList& values, const QgsFeature*,
{
double value = getDoubleValue( values.at( 0 ), parent );
int places = getIntValue( values.at( 1 ), parent );
if ( places < 0 )
{
parent->setEvalErrorString( QObject::tr( "Number of places must be positive" ) );
return QVariant();
}
return QString( "%L1" ).arg( value, 0, 'f', places );
}