I have a function inside a UWidget class and that function adds slots to a UUniformGridPanel, it works perfectly, I want to change the slot image on a key press. When I press it, it crashes with “EXCEPTION ACCESS VIOLATION” error.
Every variable and function is in the public section, the action goes like this:
- Call
UWidgetclass function fromAActorclass when E key pressed - The called function crashes the editor when trying to access ANY variable from the same class
AActor class where the UWidget class is called:
void ACPP_InteractBase::Pickup(){
GEngine->AddOnScreenDebugMessage(-1,5.f,FColor::Orange,FString::Printf(TEXT("+ %s"),(*ItemInfo.Name.ToString())));
Destroy();
TestInvBar->UpdateInventoryBarSlot(ItemInfo.Image);
}
UWidget class where the function (UpdateInventoryBarSlot) is written:
void UCPP_InventoryBar::AddInventoryBarSlots(){
for(int i = 0; i <= 9; i++)
{
UPROPERTY()
UCPP_InventoryBarSlot* InventoryBarSlot = CreateWidget<UCPP_InventoryBarSlot>(GetWorld(),InventoryBarSlotClass);
InventoryBarSlots.Add(InventoryBarSlot);
InventoryBarSlotPanel->AddChildToUniformGrid(InventoryBarSlots[i],0,i);
}
}
void UCPP_InventoryBar::UpdateInventoryBarSlot(class UTexture2D* NormalImage){
GEngine->AddOnScreenDebugMessage(-1,5.f,FColor::Orange,FString::Printf(TEXT("Works %s"), NormalImage));
if(InventoryBarSlotPanel != nullptr){
InventoryBarSlotPanel->GetPaletteCategory();
}
//InventoryBarSlots[0]->UpdateButtonNormalImage(NormalImage);
}
AddInventoryBarSlots function adds the slots without errors, and its variables are declared in the .h file, yet its not accessible in THAT function.
The DebugMessage executes if no variable is called in the function.
