Crash when calling OverridePostProcessSettings

I wrote a plugin to get the frame of the camera.
I use FViewFamily and Canvas via GetRendererModule().BeginRenderingViewFamily(&Canvas, &ViewFamily); to render the picture.
Take FMinimalViewInfo via CameraComponent->GetCameraView and pass it to OverridePostProcessSettings to set the post-processing settings, but when I modify the scene and then save, or delete some actors in the scene, the whole UE crashes.

Some of the codes are as follows:
In Tick:

CameraComponent->GetCameraView(DeltaTime, ViewInfo);

if (!ViewState.GetReference()) {
    FSceneInterface* SceneInterface = GetScene();
    const ERHIFeatureLevel::Type FeatureLevel = World->FeatureLevel.GetValue();
    ViewState.Allocate(FeatureLevel);
}

FSceneViewInitOptions ViewInitOptions;
ViewInitOptions.SceneViewStateInterface = ViewState.GetReference();

FSceneView* SceneView = new FSceneView(ViewInitOptions);

SceneView->StartFinalPostprocessSettings(ViewInitOptions.ViewOrigin);
SceneView->PreviousViewTransform = ViewInfo.PreviousViewTransform;
SceneView->OverridePostProcessSettings(ViewInfo.PostProcessSettings, ViewInfo.PostProcessBlendWeight);

for (int32 ExtraPPBlendIdx = 0; ExtraPPBlendIdx < ExtraPostProcessBlends.Num(); ++ExtraPPBlendIdx) {
    FPostProcessSettings const& PPSettings = ExtraPostProcessBlends[ExtraPPBlendIdx];
    float const Weight = ExtraPostProcessBlendWeights[ExtraPPBlendIdx];
    SceneView->OverridePostProcessSettings(PPSettings, Weight);
}

SceneView->EndFinalPostprocessSettings(ViewInitOptions);

Why did such a crash occur and what should be done about it.

咋样,解决了吗

It cause by Unreal Engine GC. Use those code to fix it.

void UXX::AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector)
{
UXXX* This = CastChecked(InThis);

if (FSceneViewStateInterface* ViewStateInterface = This->ViewState.GetReference())
{
ViewStateInterface->AddReferencedObjects(Collector);
}

UXXX’Parent::AddReferencedObjects(This, Collector);
}