QDial: don't crash when min==max and setting a value != min & max
QDial::bound() is crashing when min == max due to a division by zero. Therefore check for this condition beforehand and return min. Pick-to: 6.5 6.2 5.15 Fixes: QTBUG-104641 Change-Id: I612625af1ad18333d59a7771abfdec602301b58e Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit e4315204b1412d74842b3167c3eb9a49dc233355) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
83f7843403
commit
ef2a6ba74f
@ -58,6 +58,8 @@ int QDialPrivate::bound(int val) const
|
||||
if (wrapping) {
|
||||
if ((val >= minimum) && (val <= maximum))
|
||||
return val;
|
||||
if (minimum == maximum)
|
||||
return minimum;
|
||||
val = minimum + ((val - minimum) % (maximum - minimum));
|
||||
if (val < minimum)
|
||||
val += maximum - minimum;
|
||||
|
@ -17,6 +17,7 @@ private slots:
|
||||
void valueChanged();
|
||||
void sliderMoved();
|
||||
void wrappingCheck();
|
||||
void minEqualMaxValueOutsideRange();
|
||||
|
||||
void notchSize_data();
|
||||
void notchSize();
|
||||
@ -172,6 +173,15 @@ void tst_QDial::wrappingCheck()
|
||||
}
|
||||
}
|
||||
|
||||
// QTBUG-104641
|
||||
void tst_QDial::minEqualMaxValueOutsideRange()
|
||||
{
|
||||
QDial dial;
|
||||
dial.setRange(30, 30);
|
||||
dial.setWrapping(true);
|
||||
dial.setValue(45);
|
||||
}
|
||||
|
||||
/*
|
||||
Verify that the notchSizes calculated don't change compared
|
||||
to Qt 5.15 results for dial sizes at the edge values of the
|
||||
|
Loading…
x
Reference in New Issue
Block a user