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.

(cherry picked from commit eb5a336)
  • Loading branch information
mhugo authored and nyalldawson committed Jan 30, 2019
1 parent 9abcd0e commit ef1634c8bc93999825ad1d58f4464ced282b1816
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 ef1634c

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