COMMON: Add referencing and destruction of the OSDMessageQueue instance

Registering the OSDMessageQueue instance as an event source is now done
right after the event manager is initialised. This ensures that it is created in a
sensible place and not for example in another thread). Also registering the
event source is moved to a separate function instead of being in the constructor
to remove any issue in case some code tries to display a OSD Message very early
on (the instance would be created then, but it would be registered as an event
source later).
This commit is contained in:
Thierry Crozat 2016-10-26 23:20:30 +01:00
parent cbfa598446
commit 3ae52a61af
3 changed files with 10 additions and 1 deletions

View file

@ -51,6 +51,7 @@
#include "common/textconsole.h"
#include "common/tokenizer.h"
#include "common/translation.h"
#include "common/osd_message_queue.h"
#include "gui/gui-manager.h"
#include "gui/error.h"
@ -477,6 +478,8 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
g_eventRec.RegisterEventSource();
#endif
Common::OSDMessageQueue::instance().registerEventSource();
// Now as the event manager is created, setup the keymapper
setupKeymapper(system);
@ -615,6 +618,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
GUI::GuiManager::destroy();
Common::ConfigManager::destroy();
Common::DebugManager::destroy();
Common::OSDMessageQueue::destroy();
#ifdef ENABLE_EVENTRECORDER
GUI::EventRecorder::destroy();
#endif