Skip to content
Permalink
Browse files

Check if conversion was successful before passing to locale

  • Loading branch information
elpaso committed Jun 9, 2018
1 parent 85e34f2 commit bf810e9c50050c597576044e2b930915b0bb2811
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/core/qgsfield.cpp
@@ -244,11 +244,14 @@ QString QgsField::displayString( const QVariant &v ) const
return QString::number( v.toDouble(), 'f', d->precision );
}
}
// Other numeric types out of doubles
// Other numeric types than doubles
else if ( isNumeric() &&
! 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
return v.toString();
@@ -305,7 +308,7 @@ bool QgsField::convertCompatible( QVariant &v ) const
QVariant tmp( v );
if ( d->type == QVariant::Double && !tmp.convert( d->type ) )
{
v = v.toString().replace( ',', '.' );
v = v.toString().replace( QLocale().decimalPoint(), '.' );
}
}

0 comments on commit bf810e9

Please sign in to comment.
You can’t perform that action at this time.