Skip to content

Commit

Permalink
fix GuiHandler crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
rtri committed Feb 14, 2017
1 parent f6464d9 commit 1fe4ebb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rts/Game/UI/GuiHandler.cpp
Expand Up @@ -2969,8 +2969,8 @@ void CGuiHandler::DrawButtons() // Only called by Draw
}

const int mouseIcon = IconAtPos(mouse->lastx, mouse->lasty);
const int buttonStart = std::min(iconsCount, activePage * iconsPerPage);
const int buttonEnd = std::min(iconsCount, buttonStart + iconsPerPage);
const int buttonStart = Clamp( activePage * iconsPerPage, 0, iconsCount); // activePage can be -1
const int buttonEnd = Clamp(buttonStart + iconsPerPage, 0, iconsCount);

for (int ii = buttonStart; ii < buttonEnd; ii++) {
const IconInfo& icon = icons.at(ii);
Expand Down

2 comments on commit 1fe4ebb

@ashdnazg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was just about to commit this :D

@rtri
Copy link
Contributor

@rtri rtri commented on 1fe4ebb Feb 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a classic race condition :]

Please sign in to comment.