diff --git a/Gems/GradientSignal/Code/Source/Editor/EditorGradientSurfaceDataComponent.cpp b/Gems/GradientSignal/Code/Source/Editor/EditorGradientSurfaceDataComponent.cpp index e318e0fdf6..692576b3b3 100644 --- a/Gems/GradientSignal/Code/Source/Editor/EditorGradientSurfaceDataComponent.cpp +++ b/Gems/GradientSignal/Code/Source/Editor/EditorGradientSurfaceDataComponent.cpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace GradientSignal { @@ -61,6 +62,12 @@ namespace GradientSignal void EditorGradientSurfaceDataComponent::Deactivate() { + // Make sure any previews for this entity aren't currently trying to refresh. Otherwise, the preview job could call + // back into our FilterFunc lambda below after the entity has already been destroyed. + AZ::EntityId canceledEntity; + GradientSignal::GradientPreviewRequestBus::EventResult( + canceledEntity, GetEntityId(), &GradientSignal::GradientPreviewRequestBus::Events::CancelRefresh); + // If the preview shouldn't be active, use an invalid entityId m_gradientEntityId = AZ::EntityId(); AzFramework::EntityDebugDisplayEventBus::Handler::BusDisconnect();