I wanna see if a the widget class on a component has been set and if so set it to nullptr. Currently I’m using:
if (LockedOnWidget->GetWidgetClass() != nullptr)
{
LockedOnWidget->SetWidgetClass(nullptr);
}
And it works fine but occasionally it crashes and I don’t know why. Any reasons?
Thanks in advance.
Hi!
Can you, please, provide message that appeared with the crash?
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000000004b0
UnrealEditor_Project_TBU!ATargetDummy::EnableWidget() [C:\Users\silen\Documents\Projects\UE\Games\Project_TBU\Source\Project_TBU\TargetDummy.cpp:67]
UnrealEditor_Project_TBU!AMainCharacterTesting::TargetEnemy() [C:\Users\silen\Documents\Projects\UE\Games\Project_TBU\Source\Project_TBU\MainCharacterTesting.cpp:193]
UnrealEditor_Project_TBU!TBaseUObjectMethodDelegateInstance<0,AMainCharacterTesting,void __cdecl(void),FDefaultDelegateUserPolicy>::Execute() [C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:535]
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_EnhancedInput
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Core
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_Engine
UnrealEditor_UnrealEd
UnrealEditor_UnrealEd
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
UnrealEditor
kernel32
ntdll
Thanks for the vid!
Can you, please, show code from TargetDummy.cpp on row 67?
Oh it’s in the video both lines at where it crashes.
Oh, you’re right, thanks.
Try adding this code at the beginning of the ATargetDummy::EnableWidget()
if (LockedOnWidget == nullptr)
{
return;
}
Didn’t work but I think I found the cause. It’s something to do with the Overlap events. I’ll keep u up to date.
Ivan3z
(Ivan3z)
9
Use IsValid() function intead nullptr olso… nullptr is not enough for UObject pointers