1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Clean up menus properly on client exit (#16150)

This commit is contained in:
sfan5 2025-05-18 12:13:48 +02:00 committed by GitHub
parent dca88be81d
commit 8c8b7cb251
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 9 deletions

View file

@ -1114,8 +1114,12 @@ void Game::run()
void Game::shutdown() void Game::shutdown()
{ {
// Clear text when exiting. // Delete text and menus first
m_game_ui->clearText(); m_game_ui->clearText();
m_game_formspec.reset();
while (g_menumgr.menuCount() > 0) {
g_menumgr.deleteFront();
}
if (g_touchcontrols) if (g_touchcontrols)
g_touchcontrols->hide(); g_touchcontrols->hide();
@ -1126,11 +1130,6 @@ void Game::shutdown()
sky.reset(); sky.reset();
/* cleanup menus */
while (g_menumgr.menuCount() > 0) {
g_menumgr.deleteFront();
}
// only if the shutdown progress bar isn't shown yet // only if the shutdown progress bar isn't shown yet
if (m_shutdown_progress == 0.0f) if (m_shutdown_progress == 0.0f)
showOverlayMessage(N_("Shutting down..."), 0, 0); showOverlayMessage(N_("Shutting down..."), 0, 0);

View file

@ -217,10 +217,11 @@ void GameFormSpec::deleteFormspec()
} }
} }
GameFormSpec::~GameFormSpec() { void GameFormSpec::reset()
{
if (m_formspec) if (m_formspec)
m_formspec->quitMenu(); m_formspec->quitMenu();
this->deleteFormspec(); deleteFormspec();
} }
bool GameFormSpec::handleEmptyFormspec(const std::string &formspec, const std::string &formname) bool GameFormSpec::handleEmptyFormspec(const std::string &formspec, const std::string &formname)

View file

@ -26,7 +26,7 @@ struct GameFormSpec
{ {
void init(Client *client, RenderingEngine *rendering_engine, InputHandler *input); void init(Client *client, RenderingEngine *rendering_engine, InputHandler *input);
~GameFormSpec(); ~GameFormSpec() { reset(); }
void showFormSpec(const std::string &formspec, const std::string &formname); void showFormSpec(const std::string &formspec, const std::string &formname);
void showCSMFormSpec(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(); void disableDebugView();
bool handleCallbacks(); bool handleCallbacks();
void reset();
#ifdef __ANDROID__ #ifdef __ANDROID__
// Returns false if no formspec open // Returns false if no formspec open

View file

@ -59,6 +59,8 @@ public:
if(!m_stack.empty()) { if(!m_stack.empty()) {
m_stack.back()->setVisible(true); m_stack.back()->setVisible(true);
guienv->setFocus(m_stack.back()); guienv->setFocus(m_stack.back());
} else {
guienv->removeFocus(menu);
} }
} }