summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-09 15:21:57 +0100
committerPatric Stout <github@truebrain.nl>2021-03-10 13:41:18 +0100
commit5426cb3baf924f541bccf57aa97c6d4473546f09 (patch)
tree8104d9812c1591da5bba3f79d8e843e043890481 /src
parentb349ef6e714db1a3097f813b25373188ac627e2c (diff)
downloadopenttd-5426cb3baf924f541bccf57aa97c6d4473546f09.tar.xz
Fix: abort GRFFileScanner on exiting the game as soon as possible
This prevents the window from "freezing" when you close it during the scanning of NewGRFs, as it first would continue the action.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_config.cpp5
-rw-r--r--src/openttd.cpp2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp
index 911d266df..a0e60ef75 100644
--- a/src/newgrf_config.cpp
+++ b/src/newgrf_config.cpp
@@ -603,6 +603,9 @@ public:
bool GRFFileScanner::AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename)
{
+ /* Abort if the user stopped the game during a scan. */
+ if (_exit_game) return false;
+
GRFConfig *c = new GRFConfig(filename.c_str() + basepath_length);
bool added = true;
@@ -702,7 +705,7 @@ void DoScanNewGRFFiles(NewGRFScanCallback *callback)
/* Yes... these are the NewGRF windows */
InvalidateWindowClassesData(WC_SAVELOAD, 0, true);
InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_NEWGRF_STATE, GOID_NEWGRF_RESCANNED, true);
- if (callback != nullptr) callback->OnNewGRFsScanned();
+ if (!_exit_game && callback != nullptr) callback->OnNewGRFsScanned();
DeleteWindowByClass(WC_MODAL_PROGRESS);
SetModalProgress(false);
diff --git a/src/openttd.cpp b/src/openttd.cpp
index 035e8e5ae..235d36f01 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -1469,6 +1469,8 @@ void GameLoop()
ScanNewGRFFiles(_request_newgrf_scan_callback);
_request_newgrf_scan = false;
_request_newgrf_scan_callback = nullptr;
+ /* In case someone closed the game during our scan, don't do anything else. */
+ if (_exit_game) return;
}
ProcessAsyncSaveFinish();