Hi there,
today I discovered a problem with my code which ends in this crash log
Access violation - code c0000005 (first/second chance not available)
UE4Editor_ShadowOverMykthynaar!ABaseItem::GetItemIcon() + 0 bytes [c:\users\documents\unreal projects\shadowovermykthynaar\source\shadowovermykthynaar\private\item\baseitem.cpp:106]
UE4Editor_ShadowOverMykthynaar!ASoMHUD::DrawInventory() + 2337 bytes [c:\users\documents\unreal projects\shadowovermykthynaar\source\shadowovermykthynaar\private\somhud.cpp:429]
UE4Editor_ShadowOverMykthynaar!ASoMHUD::DrawHUD() + 117 bytes [c:\users\documents\unreal projects\shadowovermykthynaar\source\shadowovermykthynaar\private\somhud.cpp:118]
UE4Editor_Engine!AHUD::PostRender() + 337 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\hud.cpp:139]
UE4Editor_Engine!UGameViewportClient::Draw() + 6930 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\gameviewportclient.cpp:1069]
UE4Editor_Engine!FViewport::Draw() + 1223 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\engine\private\unrealclient.cpp:995]
UE4Editor_UnrealEd!UEditorEngine::Tick() + 8339 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\editor.cpp:1515]
UE4Editor_UnrealEd!UUnrealEdEngine::Tick() + 22 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\editor\unrealed\private\unrealedengine.cpp:347]
UE4Editor!FEngineLoop::Tick() + 4179 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:2257]
UE4Editor!GuardedMain() + 1404 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launch.cpp:142]
UE4Editor!GuardedMainWrapper() + 26 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:126]
UE4Editor!WinMain() + 249 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\windows\launchwindows.cpp:202]
UE4Editor!__tmainCRTStartup() + 329 bytes [f:\dd\vctools\crt\crtw32\dllstuff\crtexe.c:618]
It happens when the inventoy is open an at least one item is stored…in this case it will load the icon (from various Item BP) and display it in the inventory. The crash don’t happen instantly as soon as the inventory is open. At first everything is fine, but if I wait between 20 - 60 seconds with an open inventory window I could wait for the crash.
The called function in the BaseItem class is:
UTexture2D* ABaseItem::GetItemIcon() const
{
return ItemIcon;
}
it returns Texture2D* ItemIcon and is called by this function from my HUD Class which draws the inventory:
DrawScaledTile(TempItem[iItem]->GetItemIcon(), xPosInventory, yPosInventory, InventorySlotWidth, InventorySlotHeight, FColor(255, 255, 255, 255));
Do you have any ideas (from looking at the crash log) how I can avoid the crash? At the moment I don’t see exactly why it happens. I see that GetItemIcon() has 0 bytes in the log, but why?