From a8c6b2b619d5674318b262d710ec4e62ca8b6b35 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 4 Apr 2023 15:56:56 +0200 Subject: [PATCH] Fix crash on end play when one of the actors has been manually disabled --- Source/Engine/Level/Actor.cpp | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/Source/Engine/Level/Actor.cpp b/Source/Engine/Level/Actor.cpp index 1c2f1768e..090f3c071 100644 --- a/Source/Engine/Level/Actor.cpp +++ b/Source/Engine/Level/Actor.cpp @@ -802,18 +802,7 @@ void Actor::Initialize() void Actor::BeginPlay(SceneBeginData* data) { - // Perform additional verification ASSERT(!IsDuringPlay()); -#if BUILD_DEBUG - for (int32 i = 0; i < Children.Count(); i++) - { - ASSERT(Children[i]->IsDuringPlay() == IsDuringPlay()); - } - for (int32 i = 0; i < Scripts.Count(); i++) - { - ASSERT(Scripts[i]->IsDuringPlay() == IsDuringPlay()); - } -#endif // Set flag Flags |= ObjectFlags::IsDuringPlay; @@ -843,18 +832,7 @@ void Actor::BeginPlay(SceneBeginData* data) void Actor::EndPlay() { - // Perform additional verification ASSERT(IsDuringPlay()); -#if BUILD_DEBUG - for (int32 i = 0; i < Children.Count(); i++) - { - ASSERT(Children[i]->IsDuringPlay() == IsDuringPlay()); - } - for (int32 i = 0; i < Scripts.Count(); i++) - { - ASSERT(Scripts[i]->IsDuringPlay() == IsDuringPlay()); - } -#endif // Fire event for scripting if (IsActiveInHierarchy() && GetScene()) @@ -871,7 +849,8 @@ void Actor::EndPlay() // Call event deeper for (int32 i = 0; i < Children.Count(); i++) { - Children[i]->EndPlay(); + if (Children[i]->IsDuringPlay()) + Children[i]->EndPlay(); } // Fire event for scripting @@ -886,7 +865,8 @@ void Actor::EndPlay() // Inform attached scripts for (int32 i = 0; i < Scripts.Count(); i++) { - Scripts[i]->EndPlay(); + if (Scripts[i]->IsDuringPlay()) + Scripts[i]->EndPlay(); } // Cleanup managed object