From bb45602e36b4e8869c2d888277d706124e131904 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 2 Aug 2012 03:43:30 +0200 Subject: Crash fix when re-entering the game Throw away the old layout rather than trying to reuse it and crashing cause of collisions. --- src/game.cpp | 3 +++ src/gui/widgets/container.cpp | 6 ++++++ src/gui/widgets/container.h | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/src/game.cpp b/src/game.cpp index 2a8005f5..824eb7d1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -252,6 +252,9 @@ Game::~Game() delete mMinimapWindow; delete mMiniStatusWindow; + WindowContainer *top = static_cast(gui->getTop()); + top->clearLayout(); + destroyGuiWindows(); del_0(actorSpriteManager) diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index a2b3ee78..61211ddd 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -62,3 +62,9 @@ void Container::updateLayout() int h = area.height; getLayout().reflow(w, h); } + +void Container::clearLayout() +{ + delete mLayoutHelper; + mLayoutHelper = 0; +} diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 2b8039f4..0f1d1bb7 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -65,6 +65,12 @@ class Container : public gcn::Container */ void updateLayout(); + /** + * Removes the layout, making it forget about any widgets (needed when + * reusing a container with new widgets). + */ + void clearLayout(); + private: LayoutHelper *mLayoutHelper; }; -- cgit v1.2.3-70-g09d2