Index: ps/trunk/source/graphics/MapGenerator.cpp =================================================================== --- ps/trunk/source/graphics/MapGenerator.cpp +++ ps/trunk/source/graphics/MapGenerator.cpp @@ -41,10 +41,13 @@ // TODO: what's a good default? perhaps based on map size #define RMS_RUNTIME_SIZE 96 * 1024 * 1024 +extern bool IsQuitRequested(); + static bool MapGeneratorInterruptCallback(JSContext* UNUSED(cx)) { - if (SDL_QuitRequested()) + // This may not use SDL_IsQuitRequested(), because it runs in a thread separate to SDL, see SDL_PumpEvents + if (IsQuitRequested()) { LOGWARNING("Quit requested!"); return false; Index: ps/trunk/source/main.cpp =================================================================== --- ps/trunk/source/main.cpp +++ ps/trunk/source/main.cpp @@ -123,6 +123,11 @@ static std::chrono::high_resolution_clock::time_point lastFrameTime; +bool IsQuitRequested() +{ + return g_Shutdown == ShutdownType::Quit; +} + void QuitEngine() { g_Shutdown = ShutdownType::Quit; Index: ps/trunk/source/ps/VisualReplay.cpp =================================================================== --- ps/trunk/source/ps/VisualReplay.cpp +++ ps/trunk/source/ps/VisualReplay.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -149,8 +149,10 @@ for (const OsPath& directory : directories) { + // This cannot use IsQuitRequested(), because the current loop and that function both run in the main thread. + // So SDL events are not processed unless called explicitly here. if (SDL_QuitRequested()) - // We want to save our progress in searching through the replays + // Don't return, because we want to save our progress break; const OsPath replayFile = GetDirectoryName() / directory / L"commands.txt"; Index: ps/trunk/source/ps/tests/stub_impl_hack.h =================================================================== --- ps/trunk/source/ps/tests/stub_impl_hack.h +++ ps/trunk/source/ps/tests/stub_impl_hack.h @@ -22,6 +22,11 @@ bool g_GameRestarted; +bool IsQuitRequested() +{ + return false; +} + void QuitEngine() { }