Skip to content

Commit 8702446

Browse files
committed
Technically more accurate semantics
1 parent dc9dbc0 commit 8702446

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Entities/MovableObject.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -533,16 +533,17 @@ int MovableObject::Save(Writer &writer) const
533533
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
534534

535535
void MovableObject::DestroyScriptState() {
536-
if (ObjectScriptsInitialized()) {
537-
RunScriptedFunctionInAppropriateScripts("Destroy");
538-
539-
if (m_ThreadedLuaState) {
540-
std::lock_guard<std::recursive_mutex> lock(m_ThreadedLuaState->GetMutex());
536+
if (m_ThreadedLuaState) {
537+
std::lock_guard<std::recursive_mutex> lock(m_ThreadedLuaState->GetMutex());
538+
539+
if (ObjectScriptsInitialized()) {
540+
RunScriptedFunctionInAppropriateScripts("Destroy");
541541
m_ThreadedLuaState->RunScriptString(m_ScriptObjectName + " = nil;");
542-
m_ThreadedLuaState->UnregisterMO(this);
543-
m_ThreadedLuaState = nullptr;
544542
m_ScriptObjectName.clear();
545543
}
544+
545+
m_ThreadedLuaState->UnregisterMO(this);
546+
m_ThreadedLuaState = nullptr;
546547
}
547548
}
548549

0 commit comments

Comments
 (0)