Clear message queue when destroying GUIEngine

So it won't call font which could already been reset
This commit is contained in:
Benau 2019-09-21 11:42:35 +08:00
parent 660a35a468
commit 1d74efcd08
3 changed files with 19 additions and 1 deletions

View File

@ -834,6 +834,7 @@ namespace GUIEngine
needsUpdate.clearWithoutDeleting();
gui_messages.clear();
MessageQueue::clear();
} // clear
// ------------------------------------------------------------------------

View File

@ -384,6 +384,23 @@ void showProgressBar(int progress, const core::stringw& msg)
#endif
} // showProgressBar
// ----------------------------------------------------------------------------
/** Clear all message, called when destroying the GUIEngine.
*/
void clear()
{
#ifndef SERVER_ONLY
g_all_messages.lock();
while (!g_all_messages.getData().empty())
{
Message* msg = g_all_messages.getData().top();
delete msg;
g_all_messages.getData().pop();
}
g_all_messages.unlock();
#endif
}
} // namespace GUIEngine
// ----------------------------------------------------------------------------

View File

@ -47,6 +47,6 @@ namespace MessageQueue
void showProgressBar(int progress, const core::stringw& msg);
void updatePosition();
void update(float dt);
void clear();
}; // namespace GUIEngine
#endif