From 89e0d7e2aede862298389b53f7248c0f46ce1704 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sun, 25 Mar 2018 03:34:34 +1100 Subject: [PATCH] Events: ensure the global event context is always available The Boost unit tests have been failing since I removed the GUI2 event context since the code expects both that A: the topmost context is the global one and B: that you can't use join() to join the global context. Removing the UI event context meant the test's fake_display event_context became the only (and global) context, causing an assert. --- src/events.cpp | 4 ++-- src/wesnoth.cpp | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/events.cpp b/src/events.cpp index 87b560286e9b..e6bc4c7a9ccb 100644 --- a/src/events.cpp +++ b/src/events.cpp @@ -186,8 +186,8 @@ context::~context() // a new event context is created when e.g. a modal dialog is opened, and then // closed when that dialog is closed. Each context contains a list of the handlers // in that context. The current context is the one on the top of the stack. -// The global context must always be in the first position. -std::deque event_contexts; +// The global context must always be in the first position, so we initialize it here. +std::deque event_contexts(1); std::vector pump_monitors; diff --git a/src/wesnoth.cpp b/src/wesnoth.cpp index 4f5dd85ad4c8..6803126aab5e 100644 --- a/src/wesnoth.cpp +++ b/src/wesnoth.cpp @@ -1112,9 +1112,6 @@ int main(int argc, char** argv) sigaction(SIGCHLD, &terminate_handler, nullptr); #endif - // declare this here so that it will always be at the front of the event queue. - events::event_context global_context; - SDL_StartTextInput(); try {