Skip to content
Permalink
Browse files

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
mhugo committed Jan 30, 2019
1 parent 8c24fa8 commit eb5a3367b651e8a7d83af4af41ea0f481efc126b
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
@@ -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 )

0 comments on commit eb5a336

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