diff --git a/src/client/game.cpp b/src/client/game.cpp index f340f98e4..2c9c4fb77 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -1114,8 +1114,12 @@ void Game::run() void Game::shutdown() { - // Clear text when exiting. + // Delete text and menus first m_game_ui->clearText(); + m_game_formspec.reset(); + while (g_menumgr.menuCount() > 0) { + g_menumgr.deleteFront(); + } if (g_touchcontrols) g_touchcontrols->hide(); @@ -1126,11 +1130,6 @@ void Game::shutdown() sky.reset(); - /* cleanup menus */ - while (g_menumgr.menuCount() > 0) { - g_menumgr.deleteFront(); - } - // only if the shutdown progress bar isn't shown yet if (m_shutdown_progress == 0.0f) showOverlayMessage(N_("Shutting down..."), 0, 0); diff --git a/src/client/game_formspec.cpp b/src/client/game_formspec.cpp index 3d46ddab5..dc51247b0 100644 --- a/src/client/game_formspec.cpp +++ b/src/client/game_formspec.cpp @@ -217,10 +217,11 @@ void GameFormSpec::deleteFormspec() } } -GameFormSpec::~GameFormSpec() { +void GameFormSpec::reset() +{ if (m_formspec) m_formspec->quitMenu(); - this->deleteFormspec(); + deleteFormspec(); } bool GameFormSpec::handleEmptyFormspec(const std::string &formspec, const std::string &formname) diff --git a/src/client/game_formspec.h b/src/client/game_formspec.h index 6dff32e50..980dac47f 100644 --- a/src/client/game_formspec.h +++ b/src/client/game_formspec.h @@ -26,7 +26,7 @@ struct GameFormSpec { void init(Client *client, RenderingEngine *rendering_engine, InputHandler *input); - ~GameFormSpec(); + ~GameFormSpec() { reset(); } void showFormSpec(const std::string &formspec, const std::string &formname); void showCSMFormSpec(const std::string &formspec, const std::string &formname); @@ -43,6 +43,7 @@ struct GameFormSpec void disableDebugView(); bool handleCallbacks(); + void reset(); #ifdef __ANDROID__ // Returns false if no formspec open diff --git a/src/gui/mainmenumanager.h b/src/gui/mainmenumanager.h index 3bc8f7daa..553d6ffce 100644 --- a/src/gui/mainmenumanager.h +++ b/src/gui/mainmenumanager.h @@ -59,6 +59,8 @@ public: if(!m_stack.empty()) { m_stack.back()->setVisible(true); guienv->setFocus(m_stack.back()); + } else { + guienv->removeFocus(menu); } }