summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2020-05-10 16:04:04 +0200
committerCharles Pigott <charlespigott@googlemail.com>2020-05-10 20:02:55 +0100
commit0ed00ae1113f71b6bb34a67c013e96e69929e023 (patch)
treec487faf76b2e6bceab20cdb27f4dc01a82dc872e /src
parent3ba34a72aabf9f34fa3ae71ca6605989918b813e (diff)
downloadopenttd-0ed00ae1113f71b6bb34a67c013e96e69929e023.tar.xz
Fix: Stop any gamelog action when recovering from SlError()
Diffstat (limited to 'src')
-rw-r--r--src/gamelog.cpp5
-rw-r--r--src/gamelog.h1
-rw-r--r--src/saveload/saveload.cpp4
3 files changed, 10 insertions, 0 deletions
diff --git a/src/gamelog.cpp b/src/gamelog.cpp
index b325dc7fd..156dfe628 100644
--- a/src/gamelog.cpp
+++ b/src/gamelog.cpp
@@ -87,6 +87,11 @@ void GamelogStopAction()
if (print) GamelogPrintDebug(5);
}
+void GamelogStopAnyAction()
+{
+ if (_gamelog_action_type != GLAT_NONE) GamelogStopAction();
+}
+
/**
* Frees the memory allocated by a gamelog
*/
diff --git a/src/gamelog.h b/src/gamelog.h
index 0f21fe0f1..e7951c50c 100644
--- a/src/gamelog.h
+++ b/src/gamelog.h
@@ -27,6 +27,7 @@ enum GamelogActionType {
void GamelogStartAction(GamelogActionType at);
void GamelogStopAction();
+void GamelogStopAnyAction();
void GamelogFree(struct LoggedAction *gamelog_action, uint gamelog_actions);
void GamelogReset();
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index aeaa7a5ed..f9eebed46 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -341,6 +341,10 @@ void NORETURN SlError(StringID string, const char *extra_msg)
* when we access them during cleaning the pool dereferences of
* those indices will be made with segmentation faults as result. */
if (_sl.action == SLA_LOAD || _sl.action == SLA_PTRS) SlNullPointers();
+
+ /* Logging could be active. */
+ GamelogStopAnyAction();
+
throw std::exception();
}