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:
Colin Snover 2016-12-01 12:48:06 -06:00
parent 728e775e83
commit 94e2c67418

View file

@ -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));
}