Skip to content
Permalink
Browse files

[bugfix] Lower priority of range widget for doubles

This was the root cause of several critical bugs with
data corruption in the attribute table and forms:
SpinBox has a fixed number of decimal places, which
makes it not ideal for floating points because most
of the times it rounds the number changing it when
in edit mode even if the user has not really modified
the value by writing in the spin box or using the
controls.

So, the defult is now back to the line edit (which has
bugs in the validator, but that's another less
critical and separate issue).

Partially fixes #17861
Partially fixes #18007
  • Loading branch information
elpaso committed Jan 31, 2018
1 parent 73293e8 commit 1adc55f376c93dcc986b714c55de5db0c4de7948
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/gui/editorwidgets/qgsrangewidgetfactory.cpp
@@ -37,7 +37,8 @@ QgsEditorConfigWidget *QgsRangeWidgetFactory::configWidget( QgsVectorLayer *vl,
unsigned int QgsRangeWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
{
const QgsField field = vl->fields().at( fieldIdx );
if ( field.type() == QVariant::Int || field.type() == QVariant::Double ) return 20;
if ( field.type() == QVariant::Int ) return 20;
if ( field.type() == QVariant::Double ) return 5; // low priority because the fixed number of decimal places may alter the original data
if ( field.isNumeric() ) return 5; // widgets used support only signed 32bits (int) and double
return 0;
}

0 comments on commit 1adc55f

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