Merge pull request #9033 from mhugo/fix_20831

Fix "Allow null" in range widget (fixes #20831)
This commit is contained in:
Hugo Mercier 2019-01-30 13:32:00 +01:00 committed by GitHub
commit fa1f8762d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,7 +146,12 @@ void QgsRangeWidgetWrapper::initWidget( QWidget *editor )
if ( allowNull )
{
int stepval = step.isValid() ? step.toInt() : 1;
minval -= stepval;
int newMinval = minval - stepval;
// make sure there is room for a new value (i.e. signed integer does not overflow)
if ( newMinval < minval )
{
minval = newMinval;
}
mIntSpinBox->setValue( minval );
QgsSpinBox *intSpinBox( qobject_cast<QgsSpinBox *>( mIntSpinBox ) );
if ( intSpinBox )