Skip to content
Permalink
Browse files

Do not set min/max precision for int fields

Fixes #19050

QGIS saves integer field when I create a new real
field through field calculator (Update field works as intended)

cherry-picked from master commit 033071a
  • Loading branch information
elpaso committed Jun 4, 2018
1 parent 21d15e7 commit a7bc53652110aef9c6d998e91df1f1b112558b76
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/app/qgsfieldcalculator.cpp
@@ -483,12 +483,20 @@ void QgsFieldCalculator::setOkButtonState()
okButton->setEnabled( true );
}


void QgsFieldCalculator::setPrecisionMinMax()
{
int idx = mOutputFieldTypeComboBox->currentIndex();
int minPrecType = mOutputFieldTypeComboBox->itemData( idx, Qt::UserRole + 4 ).toInt();
int maxPrecType = mOutputFieldTypeComboBox->itemData( idx, Qt::UserRole + 5 ).toInt();
mOutputFieldPrecisionSpinBox->setEnabled( minPrecType < maxPrecType );
mOutputFieldPrecisionSpinBox->setMinimum( minPrecType );
mOutputFieldPrecisionSpinBox->setMaximum( qMax( minPrecType, qMin( maxPrecType, mOutputFieldWidthSpinBox->value() ) ) );
bool precisionIsEnabled = minPrecType < maxPrecType;
mOutputFieldPrecisionSpinBox->setEnabled( precisionIsEnabled );
// Do not set min/max if it's disabled or we'll loose the default value,
// see https://issues.qgis.org/issues/19050 - QGIS saves integer field when
// I create a new real field through field calculator (Update field works as intended)
if ( precisionIsEnabled )
{
mOutputFieldPrecisionSpinBox->setMinimum( minPrecType );
mOutputFieldPrecisionSpinBox->setMaximum( qMax( minPrecType, qMin( maxPrecType, mOutputFieldWidthSpinBox->value() ) ) );
}
}

0 comments on commit a7bc536

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