Add child to panel widget crashes

So the following blueprint crashes when it reaches the Add child function

The purpose of the blueprint is to create a scoreboard when you hold in tab, it does this by creating a widget called Scoreboard_PlayerEntry for each player and adding them to a Horizontal box panel.

I am pretty new to the unreal engine, so I do not know if it is because I have done something wrong, it compiles fine.

Here is the crash log:

MachineId:94285BBC49245FB8191AE8B5638646CB
EpicAccountId:0d450c52376c4f23b8e8d198d9f186e7

Unknown exception - code 00000001 (first/second chance not available)

Fatal error: [File:D:\BuildFarm\buildmachine_++depot+UE4-Releases+4.7\Engine\Source\Runtime\CoreUObject\Private\Templates\Casts.cpp] [Line: 11] 
Cast of Scoreboard_PlayerEntry_C //Engine//Transient.UnrealEdEngine_0:GameInstanceIaido_C_1.Scoreboard_

KERNELBASE + 35740 bytes
UE4Editor_Core!FOutputDeviceWindowsError::Serialize() + 292 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\windows\windowsplatformoutputdevices.cpp:95]
UE4Editor_Core!FMsg::Logf__VA() + 463 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\core\private\misc\outputdevice.cpp:531]
UE4Editor_CoreUObject!CastLogError() + 115 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\private\templates\casts.cpp:12]
UE4Editor_SlateRHIRenderer!CastChecked<UTexture2D,UObject>() + 173 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\public\templates\casts.h:154]
UE4Editor_SlateRHIRenderer!FSlateRHIResourceManager::FindOrCreateDynamicTextureResource() + 271 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\slaterhirenderer\private\slaterhiresourcemanager.cpp:525]
UE4Editor_SlateCore!FSlateElementBatcher::AddBoxElement() + 800 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\slatecore\private\rendering\elementbatcher.cpp:220]
UE4Editor_SlateCore!FSlateElementBatcher::AddElements() + 796 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\slatecore\private\rendering\elementbatcher.cpp:86]
UE4Editor_SlateRHIRenderer!FSlateRHIRenderer::DrawWindows_Private() + 1901 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\slaterhirenderer\private\slaterhirenderer.cpp:580]
UE4Editor_Slate!FSlateApplication::PrivateDrawWindows() + 1905 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:1123]
UE4Editor_Slate!FSlateApplication::Tick() + 2879 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\slate\private\framework\application\slateapplication.cpp:1323]
UE4Editor!FEngineLoop::Tick() + 4447 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\launch\private\launchengineloop.cpp:2284]
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]

The collapsed node is just a bunch of setters for the player entry widget’s variables.

This is completely wrong.

I did a check to see if the Scoreboard_Box is valid, and it always is, the same goes for the player entry that was just created.

Secondly,

your collapsed graph should return a widget, which you add to the content pin of the AddChild

Is completely wrong, though it might be because I did not show its internals but rather explained that it just sets variables.

In case you are unfamiliar with setting variables in blueprint, the right side pin is just a run through for convenience sake, the variable is set. The content pin (on the add child function) only retrieves data from the player entry, when the function gets executed.

Here is the collapsed graph:

Hi

Is there a reason you are just not adding it to viewport?

Else, you could have the widget permanently and just hide it when you do not require it.

This is the construction script to the widget, adding to the viewport happens in another blueprint.

But yea, a work around would be to just have all the player entries there and hide the once that are not needed, but I rather not do that work around.

So I found the solution, in a place I did not predict. I had thought the problem was something with Add Child, as Unreal would only crash when the thing got added as a child.

But looking through the call-stack, I found the problem to be something with casting…?

13. UE4Editor_SlateRHIRenderer!CastChecked<UTexture2D,UObject>() + 173 bytes [d:\buildfarm\buildmachine_++depot+ue4-releases+4.7\engine\source\runtime\coreuobject\public\templates\casts.h:154]

The thing is, my scoreboard shows a picture for each player. That picture is stored in an Texture2D array. The player entry picture (a slate brush) binding looks as following:

44991-screenshot_3.png

So I changed the Texture2D array to a Slate brush array (which is also more efficient anyway) so I no longer have to call Make Brush From Texture, and now everything works fine.