From e553eb0116548859617b21543e12e2ac485267e6 Mon Sep 17 00:00:00 2001 From: moraaar Date: Thu, 4 Nov 2021 09:27:23 +0000 Subject: [PATCH] Fixed editor crash dropping an fbx to entity inspector (#5242) The issue was that EditorActorComponent (added by the drag and drop of the FBX into the entity) continued with the loading of an actor asset even though the component is not activated due to incompatible services, which ultimately lead to logic which should never have been reached and crashing. Also fixed EditorActorComponent missing activation and deactivation of the base editor component class, which is necessary. All tests from EMotionFX.Editor.Tests passed. Signed-off-by: moraaar --- .../Editor/Components/EditorActorComponent.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp index 5da9716d15..11cf3feb3b 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp @@ -195,6 +195,8 @@ namespace EMotionFX ////////////////////////////////////////////////////////////////////////// void EditorActorComponent::Activate() { + AzToolsFramework::Components::EditorComponentBase::Activate(); + LoadActorAsset(); const AZ::EntityId entityId = GetEntityId(); @@ -225,6 +227,8 @@ namespace EMotionFX DestroyActorInstance(); m_actorAsset.Release(); + + AzToolsFramework::Components::EditorComponentBase::Deactivate(); } ////////////////////////////////////////////////////////////////////////// @@ -587,7 +591,15 @@ namespace EMotionFX if (asset) { m_actorAsset = asset; - OnAssetSelected(); + + // SetPrimaryAsset function can be called while this component is not activated + // due to incompatible services. For example by dragging and dropping a FBX to an + // entity that already has an actor or mesh component in it. Only proceed to load actor + // asset if the component is activated (by checking if it's connected to EditorActorComponentRequestBus). + if (EditorActorComponentRequestBus::Handler::BusIsConnected()) + { + OnAssetSelected(); + } } }