Fix data race between threaded init and EventManager

The initial run_dfhack_init loads shared state information that is used
by EventManager when state changes. There is a small risk that
EventManager can handle events while run_dfhack_init is still running.
develop
Pauli 2018-07-05 21:18:49 +03:00 committed by lethosor
parent a90a6b2a7b
commit 0ed5c8db39
1 changed files with 1 additions and 0 deletions

@ -1427,6 +1427,7 @@ bool Core::loadScriptFile(color_ostream &out, string fname, bool silent)
static void run_dfhack_init(color_ostream &out, Core *core) static void run_dfhack_init(color_ostream &out, Core *core)
{ {
CoreSuspender lock;
if (!df::global::world || !df::global::ui || !df::global::gview) if (!df::global::world || !df::global::ui || !df::global::gview)
{ {
out.printerr("Key globals are missing, skipping loading dfhack.init.\n"); out.printerr("Key globals are missing, skipping loading dfhack.init.\n");