mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Check if conversion was successful before passing to locale
This commit is contained in:
parent
85e34f2c92
commit
bf810e9c50
@ -244,11 +244,14 @@ QString QgsField::displayString( const QVariant &v ) const
|
|||||||
return QString::number( v.toDouble(), 'f', d->precision );
|
return QString::number( v.toDouble(), 'f', d->precision );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Other numeric types out of doubles
|
// Other numeric types than doubles
|
||||||
else if ( isNumeric() &&
|
else if ( isNumeric() &&
|
||||||
! QLocale().numberOptions() & QLocale::NumberOption::OmitGroupSeparator )
|
! QLocale().numberOptions() & QLocale::NumberOption::OmitGroupSeparator )
|
||||||
{
|
{
|
||||||
return QLocale().toString( v.toLongLong() );
|
bool ok;
|
||||||
|
qlonglong converted( v.toLongLong( &ok ) );
|
||||||
|
if ( ok )
|
||||||
|
return QLocale().toString( converted );
|
||||||
}
|
}
|
||||||
// Fallback if special rules do not apply
|
// Fallback if special rules do not apply
|
||||||
return v.toString();
|
return v.toString();
|
||||||
@ -305,7 +308,7 @@ bool QgsField::convertCompatible( QVariant &v ) const
|
|||||||
QVariant tmp( v );
|
QVariant tmp( v );
|
||||||
if ( d->type == QVariant::Double && !tmp.convert( d->type ) )
|
if ( d->type == QVariant::Double && !tmp.convert( d->type ) )
|
||||||
{
|
{
|
||||||
v = v.toString().replace( ',', '.' );
|
v = v.toString().replace( QLocale().decimalPoint(), '.' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user