I’ve been trying to set up a loading screen in C++, and I now have the following in a BeginLoadingScreen function in my GameInstance class, where it’s called before any joining/hosting functions execute. This definitely works as expected - the test/default loading screen appears and then disappears when loading has concluded.
void USpaceGameInstance::BeginLoadingScreen()
{
FLoadingScreenAttributes LoadingScreen;
LoadingScreen.bAutoCompleteWhenLoadingCompletes = true;
LoadingScreen.WidgetLoadingScreen = FLoadingScreenAttributes::NewTestLoadingScreenWidget();
GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
}
However, with the above code, if I later quit back to the menu and then quit my game, I get an access violation that the call stack suggests starts from FDefaultGameMoviePlayer’s destructor. If I don’t include the last line (where I call ‘SetupLoadingScreen’ on the movie player), this crash does not occur.
Call Stack:
FlightPrototype-Win64-DebugGame.exe!StaticFailDebug(const wchar_t * Error, const char * File, int Line, const wchar_t * Description, bool bIsEnsure) Line 167 C++
FlightPrototype-Win64-DebugGame.exe!FDebug::AssertFailed(const char * Expr, const char * File, int Line, const wchar_t * Format, ...) Line 220 C++
FlightPrototype-Win64-DebugGame.exe!FICUBreakIterator::~FICUBreakIterator() Line 72 C++
[External Code]
FlightPrototype-Win64-DebugGame.exe!FTextLayout::~FTextLayout() Line 1722 C++
[External Code]
FlightPrototype-Win64-DebugGame.exe!SharedPointerInternals::DestroyObject<FTextBlockLayout>(void * Object) Line 278 C++
[External Code]
FlightPrototype-Win64-DebugGame.exe!TIndirectArray<SBoxPanel::FSlot,FDefaultAllocator>::DestructAndFreeItems() Line 2383 C++
[External Code]
FlightPrototype-Win64-DebugGame.exe!TIndirectArray<SOverlay::FOverlaySlot,FDefaultAllocator>::DestructAndFreeItems() Line 2383 C++
FlightPrototype-Win64-DebugGame.exe!SOverlay::~SOverlay() Line 82 C++
[External Code]
FlightPrototype-Win64-DebugGame.exe!FDefaultGameMoviePlayer::~FDefaultGameMoviePlayer() Line 39 C++
[External Code]
As a result of the above, I’m questioning if this is the appropriate method for creating a loading screen. Any advice would be appreciated.
Thanks.