From 4be1e68bad1b627668a4517b00526bba6cc7acea Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Fri, 19 Nov 2021 10:45:06 -0800 Subject: [PATCH] Fix oversight from recent change to PrefabFocusHandler internals. (#5794) * Fix oversight from recent change to PrefabFocusHandler internals. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Introduce check for null instance in case this is called before the Prefab Focus Handler is initialized. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../AzToolsFramework/Prefab/PrefabFocusHandler.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp index 744c53ef5a..3d764554ef 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp @@ -212,7 +212,17 @@ namespace AzToolsFramework::Prefab AZ::EntityId PrefabFocusHandler::GetFocusedPrefabContainerEntityId([[maybe_unused]] AzFramework::EntityContextId entityContextId) const { - return m_focusedInstanceContainerEntityId; + if (m_focusedInstanceContainerEntityId.IsValid()) + { + return m_focusedInstanceContainerEntityId; + } + + if (auto instance = GetReferenceFromContainerEntityId(m_focusedInstanceContainerEntityId); instance.has_value()) + { + return instance->get().GetContainerEntityId(); + } + + return AZ::EntityId(); } bool PrefabFocusHandler::IsOwningPrefabBeingFocused(AZ::EntityId entityId) const