Stop accepting events when we are waiting for destroy event on android.

This is to make sure that there is no eg. multiple events in single loop, so that user could open another screen before window is actually closed.
This commit is contained in:
Deve 2019-04-04 22:24:14 +02:00
parent 0dcaaa871a
commit d9550fbb28
3 changed files with 4 additions and 2 deletions

View File

@ -856,7 +856,7 @@ namespace GUIEngine
{
frame++;
if (frame == 2)
GUIEngine::EventHandler::get()->startAcceptingEvents();
GUIEngine::EventHandler::get()->setAcceptEvents(true);
}
}
// ------------------------------------------------------------------------

View File

@ -114,7 +114,7 @@ namespace GUIEngine
static EventHandler* get();
static void deallocate();
void startAcceptingEvents() { m_accept_events = true; }
void setAcceptEvents(bool value) { m_accept_events = value; }
};
}

View File

@ -406,6 +406,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
else if (selection == "quit")
{
#ifdef ANDROID
GUIEngine::EventHandler::get()->setAcceptEvents(false);
ANativeActivity_finish(global_android_app->activity);
#else
StateManager::get()->popMenu();
@ -574,6 +575,7 @@ void MainMenuScreen::onDisabledItemClicked(const std::string& item)
bool MainMenuScreen::onEscapePressed()
{
#ifdef ANDROID
GUIEngine::EventHandler::get()->setAcceptEvents(false);
ANativeActivity_finish(global_android_app->activity);
return false;
#endif