Clear some global variables for android

This commit is contained in:
Benau
2019-09-21 13:05:42 +08:00
parent 380f300d74
commit f4cf63572d
3 changed files with 16 additions and 0 deletions

View File

@@ -1037,6 +1037,19 @@ namespace GUIEngine
g_loaded_screens.clearAndDeleteAll();
} // deallocate
// -----------------------------------------------------------------------
void resetGlobalVariables()
{
// Try to clear global variable for android to avoid crashes
needsUpdate.m_contents_vector.clear();
g_loaded_screens.m_contents_vector.clear();
g_current_screen = NULL;
gui_messages.clear();
#ifdef ANDROID
m_gui_functions.clear();
#endif
} // resetGlobalVariables
// -----------------------------------------------------------------------
void init(IrrlichtDevice* device_a, IVideoDriver* driver_a,
AbstractStateManager* state_manager, bool loading)

View File

@@ -116,6 +116,7 @@ namespace GUIEngine
void deallocate();
void resetGlobalVariables();
/**
* \return the irrlicht device object

View File

@@ -1701,6 +1701,8 @@ void clearGlobalVariables()
#ifdef ENABLE_WIIUSE
wiimote_manager = NULL;
#endif
World::setWorld(NULL);
GUIEngine::resetGlobalVariables();
} // clearGlobalVariables
//=============================================================================