Advanced digitizing: be nice with non-dot locales

Fix #47465
This commit is contained in:
Alessandro Pasotti 2022-02-21 17:15:01 +01:00
parent 2d2cd13c58
commit db10e7d4ec

View File

@ -616,9 +616,23 @@ double QgsAdvancedDigitizingDockWidget::parseUserInput( const QString &inputValu
QgsExpression expr( inputValue );
const QVariant result = expr.evaluate();
if ( expr.hasEvalError() )
{
ok = false;
// Be nice with non-dot locales
if ( QLocale().decimalPoint() != QChar( '.' ) && inputValue.contains( QLocale().decimalPoint() ) )
{
QgsExpression exprC( QString( inputValue ).replace( QLocale().decimalPoint(), QChar( '.' ) ) );
const QVariant resultC = exprC.evaluate();
if ( ! exprC.hasEvalError() )
{
value = resultC.toDouble( &ok );
}
}
}
else
{
value = result.toDouble( &ok );
}
return value;
}
}