Prevent crash in Landscape Canvas when creating a prefab from an open graph.

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
monroegm-disable-blank-issue-2
Chris Galvan 4 years ago
parent 7fca57a169
commit 4e46cb0a01

@ -2512,6 +2512,25 @@ namespace LandscapeCanvasEditor
{
// See comment above in OnPrefabInstancePropagationBegin
m_prefabPropagationInProgress = false;
// After prefab propagation is complete, the entity tied to one of our open
// graphs might have been deleted (e.g. if a prefab was created from that entity),
// so we need to close that graph to be safe. We need to close them in a separate
// iterator because the CloseEditor API will end up modifying m_dockWidgetsByEntity.
AZStd::vector<GraphCanvas::DockWidgetId> dockWidgetsToDelete;
for (auto [entityId, dockWidgetId] : m_dockWidgetsByEntity)
{
AZ::Entity* entity = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(entity, &AZ::ComponentApplicationRequests::FindEntity, entityId);
if (!entity)
{
dockWidgetsToDelete.push_back(dockWidgetId);
}
}
for (auto dockWidgetId : dockWidgetsToDelete)
{
CloseEditor(dockWidgetId);
}
}
void MainWindow::OnCryEditorEndCreate()

Loading…
Cancel
Save