From f3fcd24e8597feaabab67d0d354aef803958a465 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 21 Dec 2012 00:42:40 +0300 Subject: Fix possible crash with nav poinst rename dialog. --- src/game.cpp | 3 +++ src/gui/popupmenu.cpp | 9 +++++++++ src/gui/popupmenu.h | 2 ++ src/gui/viewport.cpp | 6 ++++++ src/gui/viewport.h | 2 ++ 5 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 32201a85b..f3d57df9e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -984,6 +984,9 @@ void Game::changeMap(const std::string &mapPath) { resetAdjustLevel(); + if (viewport) + viewport->clearPopup(); + // Clean up floor items, beings and particles if (actorSpriteManager) actorSpriteManager->clear(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 5a75cb71d..c6838079c 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -2204,6 +2204,15 @@ void PopupMenu::showPopup(const int x, const int y, gcn::ListModel *model) showPopup(x, y); } +void PopupMenu::clear() +{ + if (mDialog) + { + mDialog->close(); + mDialog = nullptr; + } +} + RenameListener::RenameListener() : gcn::ActionListener(), mMapItem(nullptr), diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index 431d7e7de..95cc3f65c 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -174,6 +174,8 @@ class PopupMenu final : public Popup, public LinkHandler void handleLink(const std::string &link, gcn::MouseEvent *event A_UNUSED) override; + void clear(); + private: void addPlayerRelation(std::string name); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 5175d683d..fcd62caa5 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -1033,3 +1033,9 @@ void Viewport::validateSpeed() const Game::instance()->setValidSpeed(); } } + +void Viewport::clearPopup() +{ + if (mPopupMenu) + mPopupMenu->clear(); +} diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 3724b4925..7cf02aecf 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -276,6 +276,8 @@ class Viewport final : public WindowContainer, void returnCamera(); + void clearPopup(); + protected: friend class ActorSpriteManager; -- cgit v1.2.3-70-g09d2