Changeset - r28292:edbeb8d2786a
[Not reviewed]
master
0 4 0
Peter Nelson - 12 months ago 2023-12-14 20:07:40
peter1138@openttd.org
Fix #11585: Crash when cleaning AI/GS with nested AsyncMode.

Do not throw sanity check when in_shutdown is true. This is also applied to
ExecMode and TestMode as they follow the same pattern.
4 files changed with 11 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/script/api/script_asyncmode.cpp
Show inline comments
 
@@ -48,8 +48,8 @@ ScriptAsyncMode::ScriptAsyncMode(HSQUIRR
 
void ScriptAsyncMode::FinalRelease()
 
{
 
	if (this->GetDoCommandAsyncModeInstance() != this) {
 
		/* Ignore this error if the script already died. */
 
		if (!ScriptObject::GetActiveInstance()->IsDead()) {
 
		/* Ignore this error if the script is not alive. */
 
		if (ScriptObject::GetActiveInstance()->IsAlive()) {
 
			throw Script_FatalError("Asyncmode object was removed while it was not the latest *Mode object created.");
 
		}
 
	}
src/script/api/script_execmode.cpp
Show inline comments
 
@@ -31,8 +31,8 @@ ScriptExecMode::ScriptExecMode()
 
void ScriptExecMode::FinalRelease()
 
{
 
	if (this->GetDoCommandModeInstance() != this) {
 
		/* Ignore this error if the script already died. */
 
		if (!ScriptObject::GetActiveInstance()->IsDead()) {
 
		/* Ignore this error if the script is not alive. */
 
		if (ScriptObject::GetActiveInstance()->IsAlive()) {
 
			throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
 
		}
 
	}
src/script/api/script_testmode.cpp
Show inline comments
 
@@ -31,8 +31,8 @@ ScriptTestMode::ScriptTestMode()
 
void ScriptTestMode::FinalRelease()
 
{
 
	if (this->GetDoCommandModeInstance() != this) {
 
		/* Ignore this error if the script already died. */
 
		if (!ScriptObject::GetActiveInstance()->IsDead()) {
 
		/* Ignore this error if the script is not alive. */
 
		if (ScriptObject::GetActiveInstance()->IsAlive()) {
 
			throw Script_FatalError("Testmode object was removed while it was not the latest *Mode object created.");
 
		}
 
	}
src/script/script_instance.hpp
Show inline comments
 
@@ -153,6 +153,11 @@ public:
 
	inline bool IsDead() const { return this->is_dead; }
 

	
 
	/**
 
	 * Return whether the script is alive.
 
	 */
 
	inline bool IsAlive() const { return !this->IsDead() && !this->in_shutdown; }
 

	
 
	/**
 
	 * Call the script Save function and save all data in the savegame.
 
	 */
 
	void Save();
0 comments (0 inline, 0 general)