From 5977860e090b7264de3cf13a8a1bfe356d61cd3d Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Tue, 2 Sep 2014 22:06:02 +0200 Subject: [PATCH] Fix broken coin placement in levelup dialog + possible memleak --- apps/openmw/mwgui/levelupdialog.cpp | 20 +++++++++----------- apps/openmw/mwgui/widgets.cpp | 2 ++ files/mygui/openmw_enchanting_dialog.layout | 1 - 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 32aaa6e71..021613571 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -83,13 +83,19 @@ namespace MWGui { const int coinSpacing = 10; int curX = mCoinBox->getWidth()/2 - (coinSpacing*(mCoinCount - 1) + 16*mCoinCount)/2; - for (unsigned int i=0; idetachFromWidget(); image->attachToWidget(mCoinBox); - image->setCoord(MyGUI::IntCoord(curX,0,16,16)); - curX += 16+coinSpacing; + if (i < mCoinCount) + { + mCoins[i]->setVisible(true); + image->setCoord(MyGUI::IntCoord(curX,0,16,16)); + curX += 16+coinSpacing; + } + else + mCoins[i]->setVisible(false); } } @@ -178,14 +184,6 @@ namespace MWGui mCoinCount = std::min(sMaxCoins, availableAttributes); - for (unsigned int i = 0; i < sMaxCoins; i++) - { - if (i < mCoinCount) - mCoins[i]->attachToWidget(mCoinBox); - else - mCoins[i]->detachFromWidget(); - } - mSpentAttributes.clear(); resetCoins(); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 853b90b0f..1264185a2 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -559,6 +559,8 @@ namespace MWGui Box * b = dynamic_cast(parent); if (b) b->notifyChildrenSizeChanged(); + else + break; parent = parent->getParent(); } } diff --git a/files/mygui/openmw_enchanting_dialog.layout b/files/mygui/openmw_enchanting_dialog.layout index 188c538e4..811a214e3 100644 --- a/files/mygui/openmw_enchanting_dialog.layout +++ b/files/mygui/openmw_enchanting_dialog.layout @@ -92,7 +92,6 @@ -