Skip to content

Commit fa1f876

Browse files
author
Hugo Mercier
authored
Merge pull request #9033 from mhugo/fix_20831
Fix "Allow null" in range widget (fixes #20831)
2 parents 3769faa + eb5a336 commit fa1f876

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/gui/editorwidgets/qgsrangewidgetwrapper.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ void QgsRangeWidgetWrapper::initWidget( QWidget *editor )
146146
if ( allowNull )
147147
{
148148
int stepval = step.isValid() ? step.toInt() : 1;
149-
minval -= stepval;
149+
int newMinval = minval - stepval;
150+
// make sure there is room for a new value (i.e. signed integer does not overflow)
151+
if ( newMinval < minval )
152+
{
153+
minval = newMinval;
154+
}
150155
mIntSpinBox->setValue( minval );
151156
QgsSpinBox *intSpinBox( qobject_cast<QgsSpinBox *>( mIntSpinBox ) );
152157
if ( intSpinBox )

0 commit comments

Comments
 (0)