我在编辑器模式下,处于一个空Level中,调用如下函数,希望可以创建一个新关卡,但是有很高的概率崩溃,是我的用法不正确吗?
void NewLevel(const FString &TemplateMapPath) { FGraphEventRef Task = FFunctionGraphTask::CreateAndDispatchWhenReady( [TemplateMapPath]() { if ( GEditor->ShouldAbortBecauseOfPIEWorld() ) { return; } if( FEditorFileUtils::SaveDirtyPackages(false, false, false) == false ) { return; } if ( GEditor->ShouldAbortBecauseOfUnsavedWorld() ) { return; } const FScopedBusyCursor BusyCursor; if (ULevelEditorSubsystem* LevelEditorSubsystem = GEditor->GetEditorSubsystem<ULevelEditorSubsystem>()) { if (FEditorModeTools* ModeManager = LevelEditorSubsystem->GetLevelEditorModeManager()) { ModeManager->DeactivateAllModes(); } } if (TemplateMapPath.IsEmpty()) { GEditor->NewMap(false); } else { UEditorLoadingAndSavingUtils::NewMapFromTemplate(TemplateMapPath, false); } }, TStatId(), nullptr, static_cast<ENamedThreads::Type>(ENamedThreads::GameThread)); }
崩溃堆栈
FTickTaskManager::FreeTickTaskLevel(FTickTaskLevel *) TickTaskManager.cpp:1740 ULevel::~ULevel() Level.cpp:446 ULevel::
scalar deleting destructor’(unsigned int) 0x00007ff9924be1c4
FObjectPurge::DestroyObjects(bool, double, double) GarbageCollection.cpp:826
IncrementalDestroyGarbage(bool, double) GarbageCollection.cpp:4849
IncrementalPurgeGarbage(bool, double) GarbageCollection.cpp:4525
UE::GC::PostCollectGarbageImpl<…>(EObjectFlags) GarbageCollection.cpp:5552
UE::GC::FReachabilityAnalysisState::PerformReachabilityAnalysisAndConditionallyPurgeGarbage(bool) GarbageCollection.cpp:5745
[Inlined] UE::GC::CollectGarbageInternal(EObjectFlags, bool) GarbageCollection.cpp:5302
CollectGarbage(EObjectFlags, bool) GarbageCollection.cpp:5986
UEditorEngine::Cleanse(bool, bool, const FText &, bool) EditorEngine.cpp:2817
UEditorEngine::EditorDestroyWorld(FWorldContext &, const FText &, UWorld *) EditorServer.cpp:2057
UEditorEngine::NewMap(bool) EditorServer.cpp:2183
UAIPCGEditorBPLibrary::NewLevel'::
2’::<lambda_1>::operator()() AIPCGEditorBPLibrary.cpp:286
[Inlined] UE::Core::Private::Function::TFunctionRefBase::operator()() Function.h:470
[Inlined] TFunctionGraphTaskImpl::DoTaskImpl(TUniqueFunction<…> &, Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1710
[Inlined] TFunctionGraphTaskImpl::DoTask(Type, const TRefCountPtr<…> &) TaskGraphInterfaces.h:1703
TGraphTask::ExecuteTask() TaskGraphInterfaces.h:634
UE::Tasks::Private::FTaskBase::TryExecuteTask() TaskPrivate.h:504
[Inlined] FBaseGraphTask::Execute(TArray<…> &, Type, bool) TaskGraphInterfaces.h:482
FNamedTaskThread::ProcessTasksNamedThread(int, bool) TaskGraph.cpp:779
FNamedTaskThread::ProcessTasksUntilIdle(int) TaskGraph.cpp:678
FTickTaskSequencer::ReleaseTickGroup(ETickingGroup, bool) TickTaskManager.cpp:831
FTickTaskManager::RunTickGroup(ETickingGroup, bool) TickTaskManager.cpp:1865
UWorld::RunTickGroup(ETickingGroup, bool) LevelTick.cpp:773
UWorld::Tick(ELevelTick, float) LevelTick.cpp:1511
UEditorEngine::Tick(float, bool) EditorEngine.cpp:1929
UUnrealEdEngine::Tick(float, bool) UnrealEdEngine.cpp:547
FEngineLoop::Tick() LaunchEngineLoop.cpp:5871
[Inlined] EngineTick() Launch.cpp:69
GuardedMain(const wchar_t *) Launch.cpp:190
LaunchWindowsStartup(HINSTANCE__ *, HINSTANCE__ *, char *, int, const wchar_t *) LaunchWindows.cpp:266
WinMain(HINSTANCE__ *, HINSTANCE__ *, char *, int) LaunchWindows.cpp:317
[Inlined] invoke_main() 0x00007ff6b493f0ba
__scrt_common_main_seh() 0x00007ff6b493f099
0x00007ffa7a23e8d7
0x00007ffa7b31c34c`