From 16f59809837ed9f1f5cf3a2bf145915c565287f5 Mon Sep 17 00:00:00 2001 From: Nicholas Van Sickle Date: Mon, 8 Nov 2021 09:11:13 -0800 Subject: [PATCH] Fix Prefab builder test (#5377) We were destructively moving the DOM template into the builder, leaving the Prefab system with an invalid DOM when teardown occurs. For now, this just copies the document to fix this specific test failure, but we may want to consider making `FindTemplateDom` return a const document and requiring that mutations get routed through the prefab system component to avoid similar situations in the future. Signed-off-by: nvsickle --- Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp index d33b453c01..2ed05b4dfe 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp @@ -102,7 +102,9 @@ namespace UnitTest prefabBuilderComponent.Activate(); AZStd::vector jobProducts; - auto&& prefabDom = prefabSystemComponentInterface->FindTemplateDom(parentInstance->GetTemplateId()); + // Make a copy of the template DOM, as the prefab system still owns the existing template + AzToolsFramework::Prefab::PrefabDom prefabDom; + prefabDom.CopyFrom(prefabSystemComponentInterface->FindTemplateDom(parentInstance->GetTemplateId()), prefabDom.GetAllocator(), false); ASSERT_TRUE(prefabBuilderComponent.ProcessPrefab({AZ::Crc32("pc")}, "parent.prefab", "unused", AZ::Uuid(), prefabDom, jobProducts));