LoadingScreenManager no longer crashes when removing a non-existent loading screen.

This commit is contained in:
Jamie Greunbaum 2023-03-11 16:23:48 -05:00
parent 621ef632bf
commit 9b0016a548

View File

@ -128,9 +128,6 @@ public:
void ULoadingScreenManager::Initialize(FSubsystemCollectionBase &Collection) void ULoadingScreenManager::Initialize(FSubsystemCollectionBase &Collection)
{ {
//FCoreUObjectDelegates::PreLoadMapWithContext.AddUObject(this, &ThisClass::HandlePreLoadMap);
//FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(this, &ThisClass::HandlePostLoadMap);
const UGameInstance *LocalGameInstance = this->GetGameInstance(); const UGameInstance *LocalGameInstance = this->GetGameInstance();
check(LocalGameInstance); check(LocalGameInstance);
} }
@ -139,9 +136,6 @@ void ULoadingScreenManager::Deinitialize()
{ {
this->StopBlockingInput(); this->StopBlockingInput();
this->RemoveWidgetFromViewport(); this->RemoveWidgetFromViewport();
//FCoreUObjectDelegates::PreLoadMap.RemoveAll(this);
//FCoreUObjectDelegates::PostLoadMapWithWorld.RemoveAll(this);
} }
bool ULoadingScreenManager::ShouldCreateSubsystem(UObject *Outer) const bool ULoadingScreenManager::ShouldCreateSubsystem(UObject *Outer) const
@ -185,7 +179,6 @@ class ULoadingScreenWidget *ULoadingScreenManager::ShowLoadingScreen()
if (this->LoadingScreenUMGWidget = CreateWidget<ULoadingScreenWidget>(LocalGameInstance, LoadingScreenWidgetClass, NAME_None)) if (this->LoadingScreenUMGWidget = CreateWidget<ULoadingScreenWidget>(LocalGameInstance, LoadingScreenWidgetClass, NAME_None))
{ {
this->LoadingScreenWidget = this->LoadingScreenUMGWidget->TakeWidget(); this->LoadingScreenWidget = this->LoadingScreenUMGWidget->TakeWidget();
this->LoadingScreenUMGWidget->OnLoadScreenClosed.BindUObject(this, &ULoadingScreenManager::RemoveLoadingScreen);
} }
else else
{ {
@ -209,10 +202,15 @@ class ULoadingScreenWidget *ULoadingScreenManager::ShowLoadingScreen()
} }
void ULoadingScreenManager::HideLoadingScreen() void ULoadingScreenManager::HideLoadingScreen()
{
if (this->bCurrentlyShowingLoadingScreen)
{ {
this->ChangePerformanceSettings(/*bEnableLoadingScreen=*/ false); this->ChangePerformanceSettings(/*bEnableLoadingScreen=*/ false);
this->LoadingScreenUMGWidget->OnLoadScreenClosed.BindUObject(this, &ULoadingScreenManager::RemoveLoadingScreen);
this->LoadingScreenUMGWidget->BeginFadeOut(); this->LoadingScreenUMGWidget->BeginFadeOut();
} }
}
void ULoadingScreenManager::RemoveLoadingScreen() void ULoadingScreenManager::RemoveLoadingScreen()
{ {