Uniform Grid Panel not allocating memory when use meta=(BindWidget) in Play Mode

Just as the title. Here’s my code:


as UniformPanelGrid not initialized correctly during Play mode, it crashes with exception:
Fatal error! Error LogWindows Unhandled Exception: EXCEPTION_ACCESS_VIOLATION writing address 0x0000000000000290
Exception thrown at line in the image above (from the log)

Code still works well in Designer:

Can anyone point me in the right direction? Thank you so much in advance!

Context: I’m trying to build a widget procedurally (adding slots by code, rather than fixed size), if anybody can have another way without neccessarily fixing the bug, please share~!

My inspection so far: For sure that it’s due to not being initialized correctly (not allocating mem on Play Mode), I’ve tried allocating mem by creating new widget and assign it to UniformGrid and it works fine (no exception, but no slot added in play mode).
My speculation is that in PlayMode, Uniform Grid slot is gonna be fixed-size mem alloc (probably for optimization), making it unable to process dynamic operations?

More detailed log:
Warning LogTemp AMyProjectCharacter::BeginPlay() is called
Warning LogTemp UHUD_WC::AddToScreen() is called
Warning LogTemp UActionBar_WC::NativePreConstruct() is called
Error LogWindows === Critical error: ===
Error LogWindows Fatal error!
Error LogWindows Unhandled Exception: EXCEPTION_ACCESS_VIOLATION writing address 0x0000000000000290
Error LogWindows [Callstack] 0x00007ffd43c2695d UnrealEditor-SlateCore.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd43c2404d UnrealEditor-SlateCore.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31488f71 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd314884d7 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31439ef7 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd3146b0ba UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31346955 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31435d0a UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd119bb735 UnrealEditor-MyProject.dll!UActionBar_WC::NativeConstruct() [J:\mmorpg_front\MyProject\Source\MyProject\Private\InventorySystem\Widget\ActionBar_WC.cpp:30]
Error LogWindows [Callstack] 0x00007ffd31488f71 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd314884d7 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd3134dc2e UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd313c7c86 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31488661 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd314884d7 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31472106 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31488661 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd314884d7 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd31437403 UnrealEditor-UMG.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd33b24e3f UnrealEditor-Engine.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd359182c2 UnrealEditor-Engine.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd34459111 UnrealEditor-Engine.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd35844948 UnrealEditor-Engine.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd34413a15 UnrealEditor-Engine.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd326e9198 UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd3271e566 UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd326e9c42 UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd3273cd2a UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd32740537 UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd3273fe21 UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd320dd953 UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffd32a69f56 UnrealEditor-UnrealEd.dll!UnknownFunction []
Error LogWindows [Callstack] 0x00007ff6b96d82f6 UnrealEditor.exe!UnknownFunction []
Error LogWindows [Callstack] 0x00007ff6b96f0d9c UnrealEditor.exe!UnknownFunction []
Error LogWindows [Callstack] 0x00007ff6b96f0e8a UnrealEditor.exe!UnknownFunction []
Error LogWindows [Callstack] 0x00007ff6b96f3c4d UnrealEditor.exe!UnknownFunction []
Error LogWindows [Callstack] 0x00007ff6b9705534 UnrealEditor.exe!UnknownFunction []
Error LogWindows [Callstack] 0x00007ff6b97086e6 UnrealEditor.exe!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffda7ca7034 KERNEL32.DLL!UnknownFunction []
Error LogWindows [Callstack] 0x00007ffda8f82651 ntdll.dll!UnknownFunction []

Are you sure the widget you are creating during play is of the Blueprint type and not the C++ class?

It’s not an allocation issue - that pointer simply isn’t populated. It’s a good idea to mark your C++ widget classes as “Abstract” to prevent them being spawned or selectable from drop-downs.

Note that also, you should be using the static CreateWidget() function and passing in this as the owner - not calling ConstructWidget<> on the widget tree. This ensures that the widget is properly initialized and also sets the correct player context.

1 Like

Sorry guys, it’s just that my ActionSlot Widget was having some error that prevent it (or probably its parent) from being able to call ToSharedRef() (in TakeWidget_Private()) which is a part of the TakeWidget procedure in the series of callbacks that AddToViewPort() calls (which is what I was doing but not captured here). By not being able to return a proper pointer from all the complicated casting and stuffs, it becomes a dangling pointer(?) and cannot be called upon…

I guess next time I’ll have to double check next time for all the child widget classes and ensure them running properly before adding to the another widget!

Great! Many thanks for the tips! I’ve actually ensure that class is the Blueprint Class, not the cpp class :smiley: