Add resetGlobalVariables for message queue

This commit is contained in:
Benau 2020-01-11 00:21:22 +08:00
parent 13fca9a0eb
commit 1e4b0ccb4e
3 changed files with 21 additions and 4 deletions

View File

@ -1047,6 +1047,7 @@ namespace GUIEngine
g_loaded_screens.m_contents_vector.clear();
g_current_screen = NULL;
gui_messages.clear();
MessageQueue::resetGlobalVariables();
#ifdef ANDROID
m_gui_functions.clear();
#endif

View File

@ -274,7 +274,7 @@ Synchronised<std::priority_queue<Message*, std::vector<Message*>,
// ============================================================================
/** The Storage for a Static Message */
StaticTextMessage* g_static_message = 0;
StaticTextMessage* g_static_message = NULL;
// ============================================================================
/** Add any message to the message queue.
@ -400,7 +400,7 @@ void addStatic(MessageType mt, const irr::core::stringw &message)
if (ProfileWorld::isNoGraphics())
return;
delete g_static_message;
g_static_message = 0;
g_static_message = NULL;
g_static_message = new StaticTextMessage(mt, message);
#endif
} // addStatic
@ -470,7 +470,7 @@ void discardStatic()
{
#ifndef SERVER_ONLY
delete g_static_message;
g_static_message = 0;
g_static_message = NULL;
s_msg_raise = 0;
#endif
} // discardStatic
@ -482,7 +482,7 @@ void clear()
{
#ifndef SERVER_ONLY
delete g_static_message;
g_static_message = 0;
g_static_message = NULL;
g_all_messages.lock();
while (!g_all_messages.getData().empty())
{
@ -494,6 +494,21 @@ void clear()
#endif
}
// ----------------------------------------------------------------------------
/** Reset global variables (for clear starting in android).
*/
void resetGlobalVariables()
{
#ifndef SERVER_ONLY
g_container = NULL;
g_static_container = NULL;
g_static_message = NULL;
s_msg_raise = 0;
while (!g_all_messages.getData().empty())
g_all_messages.getData().pop();
#endif
}
} // namespace GUIEngine
// ----------------------------------------------------------------------------

View File

@ -50,5 +50,6 @@ namespace MessageQueue
void update(float dt);
void discardStatic();
void clear();
void resetGlobalVariables();
}; // namespace GUIEngine
#endif