Skip to content

Commit 1adc55f

Browse files
committed
[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
1 parent 73293e8 commit 1adc55f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/gui/editorwidgets/qgsrangewidgetfactory.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ QgsEditorConfigWidget *QgsRangeWidgetFactory::configWidget( QgsVectorLayer *vl,
3737
unsigned int QgsRangeWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
3838
{
3939
const QgsField field = vl->fields().at( fieldIdx );
40-
if ( field.type() == QVariant::Int || field.type() == QVariant::Double ) return 20;
40+
if ( field.type() == QVariant::Int ) return 20;
41+
if ( field.type() == QVariant::Double ) return 5; // low priority because the fixed number of decimal places may alter the original data
4142
if ( field.isNumeric() ) return 5; // widgets used support only signed 32bits (int) and double
4243
return 0;
4344
}

0 commit comments

Comments
 (0)