summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-01 12:28:54 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-01 12:28:54 +0300
commit356ac7c52ae8cebc5df4d08e1e2cf30cfd66d869 (patch)
tree788266bf378895c065e00a83b2a58cf8427f63d4 /src/gui/widgets
parent1bf7aa922ded964035f85444b42c8f8aa4668e92 (diff)
downloadmanaplus-356ac7c52ae8cebc5df4d08e1e2cf30cfd66d869.tar.gz
manaplus-356ac7c52ae8cebc5df4d08e1e2cf30cfd66d869.tar.bz2
manaplus-356ac7c52ae8cebc5df4d08e1e2cf30cfd66d869.tar.xz
manaplus-356ac7c52ae8cebc5df4d08e1e2cf30cfd66d869.zip
improve size() usage in setupitem.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/setupitem.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 8be4696e1..8be7dd520 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -895,9 +895,15 @@ void SetupItemSlider2::updateLabel()
{
int val = static_cast<int>(mSlider->getValue()) - mMin;
if (val < 0)
+ {
val = 0;
- else if (val >= static_cast<signed>(mValues->size()))
- val = static_cast<signed>(mValues->size()) - 1;
+ }
+ else
+ {
+ const int sz = static_cast<signed>(mValues->size());
+ if (val >= sz)
+ val = sz - 1;
+ }
std::string str = mValues->at(val);
mLabel2->setCaption(str);
}