From 3466457d69d718f1d1b99a63864474911d9a6f09 Mon Sep 17 00:00:00 2001 From: ArseniyShestakov Date: Wed, 7 Jan 2015 13:10:48 +0300 Subject: [PATCH] Fix crash on opening of Hill Fort window and attempt to upgrade one stack This one fixes issue 1899 --- client/windows/GUIClasses.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index f3bfe5cf1..8046f379f 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1392,10 +1392,9 @@ CHillFortWindow::CHillFortWindow(const CGHeroInstance *visitor, const CGObjectIn for (int i = 0; i < slotsCount; i++) { currState[i] = getState(SlotID(i)); - upgrade[i] = new CButton(Point(107 + i * 76, 171), "", CButton::tooltip(getTextForSlot(SlotID(i))), [&]{ makeDeal(SlotID(i)); }, SDLK_1 + i); + upgrade[i] = new CButton(Point(107 + i * 76, 171), "", CButton::tooltip(getTextForSlot(SlotID(i))), [=]{ makeDeal(SlotID(i)); }, SDLK_1 + i); for (auto image : { "APHLF1R.DEF", "APHLF1Y.DEF", "APHLF1G.DEF" }) upgrade[i]->addImage(image); - upgrade[i]->block(currState[i] == -1); } currState[slotsCount] = getState(SlotID(slotsCount)); @@ -1431,7 +1430,7 @@ void CHillFortWindow::updateGarrisons() } currState[i] = newState; - upgrade[i]->setIndex(newState); + upgrade[i]->setIndex(currState[i] == -1 ? 0 : currState[i]); upgrade[i]->block(currState[i] == -1); upgrade[i]->addHoverText(CButton::NORMAL, getTextForSlot(SlotID(i))); }