Hello everyone,
i post this because it’s been 3 hours i’m trying to resolve this strange error.
This causes my editor to crash, so i now launch my editor with visual studio on debug mode.
ULPLAYERCONTROLLER.H:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
TSubclassOf<class UUserWidget> wMainMenu;
UUserWidget* wMainMenuRef;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets")
TSubclassOf<class UUserWidget> wPlayMenu;
UUserWidget* wPlayMenuRef;
so here are my references to my widgets
i initialize them here:
ULPLAYERCONTROLLER.CPP:
void AULPlayerControllerBase::SetupMenuWidgets()
{
if (IsLocalPlayerController())
{
if (wPlayMenu)
{
wPlayMenuRef = CreateWidget<UUserWidget>(this, wPlayMenu);
}
if (wMainMenu)
{
wMainMenuRef = CreateWidget<UUserWidget>(this, wMainMenu);
}
}
}
and then i show them here:
ULPLAYERCONTROLLER.CPP
void AULPlayerControllerBase::BeginPlayMenuState()
{
if (wPlayMenu)
{
if (wPlayMenuRef)
{
if (!wPlayMenuRef->IsInViewport())
{
wPlayMenuRef->AddToViewport();
}
wPlayMenuRef->SetVisibility(ESlateVisibility::Visible);
}
bShowMouseCursor = true;
}
}
void AULPlayerControllerBase::BeginMainMenuState()
{
if (wMainMenuRef)
{
if (!wMainMenuRef->IsInViewport())
{
wMainMenuRef->AddToViewport();
}
wMainMenuRef->SetVisibility(ESlateVisibility::Visible);
bShowMouseCursor = true;
}
}
the thing i dont understand is that the project launch well, the main menu is showed and then when i naviguate to my Play Menu, i have an exception :
Exception thrown at 0x00007FF9641289F6 (UE4Editor-UMG.dll) in UE4Editor.exe: 0xC0000005: Read access violation of location 0xFFFFFFFFFFFFFFFF.
the exception is thrown at this line:
if (!wPlayMenuRef->IsInViewport())
the thing is that i checked this variable and this code should not be accessed if the wplaymenuref is a null pointer.
Thank you for helping me, i’m confused !