aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorColin Snover2016-12-01 12:48:06 -0600
committerColin Snover2016-12-01 13:04:55 -0600
commit94e2c674186744db55f548032f889f8e122b9c97 (patch)
treef02765bc1114f81eac8c6e01704ca6d190567b1b /gui
parent728e775e839f490d2be58e169cc7313571132ca6 (diff)
downloadscummvm-rg350-94e2c674186744db55f548032f889f8e122b9c97.tar.gz
scummvm-rg350-94e2c674186744db55f548032f889f8e122b9c97.tar.bz2
scummvm-rg350-94e2c674186744db55f548032f889f8e122b9c97.zip
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.
Diffstat (limited to 'gui')
-rw-r--r--gui/widget.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 898d5671c6..850fad0e5f 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -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));
}