GUI: Fix crash when slider values are out-of-bounds
Out-of-bounds values are always indicative of a bug somewhere else, but at least not crashing here allows the user to recover by interacting with the slider control. The error will still be obvious because the associated text field will display the original weird value.
This commit is contained in:
parent
728e775e83
commit
94e2c67418
1 changed files with 2 additions and 0 deletions
|
@ -701,10 +701,12 @@ void SliderWidget::drawWidget() {
|
|||
}
|
||||
|
||||
int SliderWidget::valueToBarWidth(int value) {
|
||||
value = CLIP(value, _valueMin, _valueMax);
|
||||
return (_w * (value - _valueMin) / (_valueMax - _valueMin));
|
||||
}
|
||||
|
||||
int SliderWidget::valueToPos(int value) {
|
||||
value = CLIP(value, _valueMin, _valueMax);
|
||||
return ((_w - 1) * (value - _valueMin + 1) / (_valueMax - _valueMin));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue