Fix crash when destroying actor that was left in enabled state

#3880
This commit is contained in:
Wojtek Figat
2026-03-10 17:01:57 +01:00
parent 5509bc4989
commit 3bbaa7025a

View File

@@ -178,21 +178,20 @@ void Actor::OnDeleteObject()
_scene = nullptr;
}
}
else if (_parent)
else
{
// Unlink from the parent
_parent->Children.RemoveKeepOrder(this);
_parent->_isHierarchyDirty = true;
_parent = nullptr;
_scene = nullptr;
if (_isEnabled)
OnDisable();
if (_parent)
{
// Unlink from the parent
_parent->Children.RemoveKeepOrder(this);
_parent->_isHierarchyDirty = true;
_parent = nullptr;
_scene = nullptr;
}
}
// Ensure to exit gameplay in a valid way
ASSERT(!IsDuringPlay());
#if BUILD_DEBUG || BUILD_DEVELOPMENT
ASSERT(!_isEnabled);
#endif
// Fire event
Deleted(this);