Merge pull request #4243 from aws-lumberyard-dev/cgalvan/FixLCPrefabCrash

Prevent crash in Landscape Canvas when creating a prefab from an open graph.
monroegm-disable-blank-issue-2
Chris Galvan 5 years ago committed by GitHub
commit ec4e6a6c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2512,6 +2512,26 @@ 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).
// Any open graphs tied to an entity that no longer exists will need to be closed.
// 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