From 7901fe8625b3bbd31a569f0c7dd89a7d43cd8830 Mon Sep 17 00:00:00 2001 From: AMZN-daimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Mon, 19 Apr 2021 21:52:10 -0700 Subject: [PATCH] Reset the whole Qt model when an entry in the EditorEntityModel is removed. (#48) (#82) An optimization introduced in Prefab mode currently changes the relative ordering of children, causing stale QModelIndex variables to still be referenced and crash the Editor sporadically. This change is theoretically a bit slower, but still much faster than the pre-optimization times. Co-authored-by: Shirang Jia Co-authored-by: Shirang Jia --- .../AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp index ea281aacf7..de10ae18b4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp @@ -1344,14 +1344,15 @@ namespace AzToolsFramework emit EnableSelectionUpdates(false); auto parentIndex = GetIndexFromEntity(parentId); auto childIndex = GetIndexFromEntity(childId); - beginRemoveRows(parentIndex, childIndex.row(), childIndex.row()); + beginResetModel(); } void EntityOutlinerListModel::OnEntityInfoUpdatedRemoveChildEnd(AZ::EntityId parentId, AZ::EntityId childId) { (void)childId; AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework); - endRemoveRows(); + + endResetModel(); //must refresh partial lock/visibility of parents m_isFilterDirty = true;