From 73dca7e9e2e3d806f0b48355343df6a68a7e4e1f Mon Sep 17 00:00:00 2001 From: srikappa Date: Mon, 3 May 2021 10:07:44 -0700 Subject: [PATCH 1/2] Fix Editor crash when slices are deleted with prefabs enabled --- .../ComponentEntityEditorPlugin/SandboxIntegration.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp index ecfb155d79..7a418a1f2e 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp @@ -302,17 +302,20 @@ void SandboxIntegrationManager::OnCatalogAssetAdded(const AZ::Data::AssetId& ass // operation writing to shared resource is queued on main thread. void SandboxIntegrationManager::OnCatalogAssetRemoved(const AZ::Data::AssetId& assetId, const AZ::Data::AssetInfo& assetInfo) { + bool isPrefabSystemEnabled = false; + AzFramework::ApplicationRequests::Bus::BroadcastResult(isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); + // Check to see if the removed slice asset has any instance in the level, then check if // those dangling instances are directly under the root slice (not sub-slices). If yes, // detach them and save necessary information so they can be restored when their slice asset // comes back. - if (assetInfo.m_assetType == AZ::AzTypeInfo::Uuid()) + if (!isPrefabSystemEnabled && assetInfo.m_assetType == AZ::AzTypeInfo::Uuid()) { AZ::SliceComponent* rootSlice = nullptr; AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(rootSlice, &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice); - AZ_Assert(rootSlice, "Editor root slice missing!"); + AZ_Assert(rootSlice != nullptr, "Editor root slice missing!"); AZStd::vector entitiesToDetach; const AZ::SliceComponent::SliceList& subSlices = rootSlice->GetSlices(); From d8145d33e94118527de48a6d2e3b54904cfdd73e Mon Sep 17 00:00:00 2001 From: srikappa Date: Mon, 3 May 2021 10:13:55 -0700 Subject: [PATCH 2/2] Reverted an assert condition to its previous state --- .../Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp index 7a418a1f2e..724664b1dc 100644 --- a/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp +++ b/Code/Sandbox/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp @@ -315,7 +315,7 @@ void SandboxIntegrationManager::OnCatalogAssetRemoved(const AZ::Data::AssetId& a AZ::SliceComponent* rootSlice = nullptr; AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::BroadcastResult(rootSlice, &AzToolsFramework::SliceEditorEntityOwnershipServiceRequestBus::Events::GetEditorRootSlice); - AZ_Assert(rootSlice != nullptr, "Editor root slice missing!"); + AZ_Assert(rootSlice, "Editor root slice missing!"); AZStd::vector entitiesToDetach; const AZ::SliceComponent::SliceList& subSlices = rootSlice->GetSlices();