Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix "Allow null" in range widget (fixes #20831)
By default a range widget is built with a minimum value set to the
minimal integer that is possible to represent. When "allow null" is
enabled, a new value (minvalue - 1) is inserted. With the default
value, we then had an integer overflow.
  • Loading branch information
Hugo Mercier committed Jan 30, 2019
1 parent 8c24fa8 commit eb5a336
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
Expand Up @@ -145,7 +145,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 )
Expand Down

0 comments on commit eb5a336

Please sign in to comment.