mirror of https://github.com/OpenTTD/OpenTTD
(svn r27379) -Codechange: Do not throw in the destructors of ScriptTest/ExecMode.
parent
d818e1779c
commit
e5d105900d
|
@ -25,7 +25,12 @@ int32 SimpleCountedObject::Release()
|
||||||
int32 res = --m_ref_cnt;
|
int32 res = --m_ref_cnt;
|
||||||
assert(res >= 0);
|
assert(res >= 0);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
FinalRelease();
|
try {
|
||||||
|
FinalRelease(); // may throw, for example ScriptTest/ExecMode
|
||||||
|
} catch (...) {
|
||||||
|
delete this;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -30,7 +30,7 @@ ScriptExecMode::ScriptExecMode()
|
||||||
this->SetDoCommandMode(&ScriptExecMode::ModeProc, this);
|
this->SetDoCommandMode(&ScriptExecMode::ModeProc, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptExecMode::~ScriptExecMode()
|
void ScriptExecMode::FinalRelease()
|
||||||
{
|
{
|
||||||
if (this->GetDoCommandModeInstance() != this) {
|
if (this->GetDoCommandModeInstance() != this) {
|
||||||
/* Ignore this error if the script already died. */
|
/* Ignore this error if the script already died. */
|
||||||
|
@ -38,5 +38,9 @@ ScriptExecMode::~ScriptExecMode()
|
||||||
throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
|
throw Script_FatalError("ScriptExecMode object was removed while it was not the latest *Mode object created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptExecMode::~ScriptExecMode()
|
||||||
|
{
|
||||||
this->SetDoCommandMode(this->last_mode, this->last_instance);
|
this->SetDoCommandMode(this->last_mode, this->last_instance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ public:
|
||||||
* in when the instance was created.
|
* in when the instance was created.
|
||||||
*/
|
*/
|
||||||
~ScriptExecMode();
|
~ScriptExecMode();
|
||||||
|
|
||||||
|
virtual void FinalRelease();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCRIPT_EXECMODE_HPP */
|
#endif /* SCRIPT_EXECMODE_HPP */
|
||||||
|
|
|
@ -30,7 +30,7 @@ ScriptTestMode::ScriptTestMode()
|
||||||
this->SetDoCommandMode(&ScriptTestMode::ModeProc, this);
|
this->SetDoCommandMode(&ScriptTestMode::ModeProc, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptTestMode::~ScriptTestMode()
|
void ScriptTestMode::FinalRelease()
|
||||||
{
|
{
|
||||||
if (this->GetDoCommandModeInstance() != this) {
|
if (this->GetDoCommandModeInstance() != this) {
|
||||||
/* Ignore this error if the script already died. */
|
/* Ignore this error if the script already died. */
|
||||||
|
@ -38,5 +38,9 @@ ScriptTestMode::~ScriptTestMode()
|
||||||
throw Script_FatalError("Testmode object was removed while it was not the latest *Mode object created.");
|
throw Script_FatalError("Testmode object was removed while it was not the latest *Mode object created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptTestMode::~ScriptTestMode()
|
||||||
|
{
|
||||||
this->SetDoCommandMode(this->last_mode, this->last_instance);
|
this->SetDoCommandMode(this->last_mode, this->last_instance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
* in when the instance was created.
|
* in when the instance was created.
|
||||||
*/
|
*/
|
||||||
~ScriptTestMode();
|
~ScriptTestMode();
|
||||||
|
|
||||||
|
virtual void FinalRelease();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCRIPT_TESTMODE_HPP */
|
#endif /* SCRIPT_TESTMODE_HPP */
|
||||||
|
|
Loading…
Reference in New Issue