Skip to content

Commit

Permalink
Merge pull request #7143 from elpaso/bugfix-19050-field-calc-save-rea…
Browse files Browse the repository at this point in the history
…l-as-int

Do not set min/max precision for int fields
  • Loading branch information
elpaso authored Jun 2, 2018
2 parents f68f288 + 033071a commit 79ba0ee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app/qgsfieldcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,16 @@ void QgsFieldCalculator::setPrecisionMinMax()
int idx = mOutputFieldTypeComboBox->currentIndex();
int minPrecType = mOutputFieldTypeComboBox->itemData( idx, Qt::UserRole + FTC_MINPREC_IDX ).toInt();
int maxPrecType = mOutputFieldTypeComboBox->itemData( idx, Qt::UserRole + FTC_MAXPREC_IDX ).toInt();
mOutputFieldPrecisionSpinBox->setEnabled( minPrecType < maxPrecType );
mOutputFieldPrecisionSpinBox->setMinimum( minPrecType );
mOutputFieldPrecisionSpinBox->setMaximum( std::max( minPrecType, std::min( 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( std::max( minPrecType, std::min( maxPrecType, mOutputFieldWidthSpinBox->value() ) ) );
}
}

void QgsFieldCalculator::showHelp()
Expand Down

0 comments on commit 79ba0ee

Please sign in to comment.