Fix android exit crash

This commit is contained in:
Benau 2019-04-04 07:59:32 +08:00
parent d8a9accba3
commit b03af63ab7
3 changed files with 20 additions and 4 deletions

View File

@ -405,7 +405,11 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
}
else if (selection == "quit")
{
#ifdef ANDROID
ANativeActivity_finish(global_android_app->activity);
#else
StateManager::get()->popMenu();
#endif
return;
}
else if (selection == "about")
@ -564,3 +568,15 @@ void MainMenuScreen::onDisabledItemClicked(const std::string& item)
}
#endif
} // onDisabledItemClicked
// ----------------------------------------------------------------------------
bool MainMenuScreen::onEscapePressed()
{
#ifdef ANDROID
ANativeActivity_finish(global_android_app->activity);
return false;
#endif
return true;
} // onEscapePressed

View File

@ -58,6 +58,10 @@ public:
/** \brief implement callback from parent class GUIEngine::Screen */
virtual void onDisabledItemClicked(const std::string& item) OVERRIDE;
/** \brief implement optional callback from parent
* class GUIEngine::Screen */
virtual bool onEscapePressed() OVERRIDE;
};
#endif

View File

@ -252,13 +252,9 @@ void StateManager::onTopMostScreenChanged()
void StateManager::onStackEmptied()
{
#ifdef ANDROID
ANativeActivity_finish(global_android_app->activity);
#else
GUIEngine::cleanUp();
GUIEngine::deallocate();
main_loop->abort();
#endif
} // onStackEmptied
// ============================================================================