Skip to content

Commit

Permalink
CSplitWindow: added input check
Browse files Browse the repository at this point in the history
This one fixes issue 1952
  • Loading branch information
ArseniyShestakov committed Dec 23, 2014
1 parent 8a697f2 commit 94d0e54
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions client/windows/GUIClasses.cpp
Expand Up @@ -400,14 +400,25 @@ CSplitWindow::CSplitWindow(const CCreature * creature, std::function<void(int, i

void CSplitWindow::setAmountText(std::string text, bool left)
{
try
{
setAmount(boost::lexical_cast<int>(text), left);
slider->moveTo(rightAmount - rightMin);
}
catch(boost::bad_lexical_cast &)
int amount = 0;
if (text.length())
{
try
{
amount = boost::lexical_cast<int>(text);
}
catch(boost::bad_lexical_cast &)
{
amount = left ? leftAmount : rightAmount;
}

int total = leftAmount + rightAmount;
if (amount > total)
amount = total;
}

setAmount(amount, left);
slider->moveTo(rightAmount - rightMin);
}

void CSplitWindow::setAmount(int value, bool left)
Expand Down

0 comments on commit 94d0e54

Please sign in to comment.