Hey, I’m trying to fill in a Panel Widget dynamically on runtime with the following code:
UMainDebugFunctionLibrary::DebugLogWithObject(this, "Updating Section Tree", EDebuggingType::DT_Log);
for(const auto& section : ClueTree.ClueTreeNodes)
{
UpdateSectionSize(section.Value.NodeName, section.Value.Clues.Num());
}
// Iterate through the Collected Clue Sections
for(const auto& section : CollectedClueSections)
{
if(IsValid(section.Value))
{
UMainDebugFunctionLibrary::DebugLogWithObject(this, "Section Value [" +section.Key +"] Valid", EDebuggingType::DT_Log);
GetParent()->AddChild(section.Value);
}
}
and the UpdateSectionSize function does:
void UClueListManager::UpdateSectionSize(const FString& ClueLocation, int SectionSize)
{
UMainDebugFunctionLibrary::DebugLogWithObject(this, "Section Size: " +FString::FromInt(SectionSize), EDebuggingType::DT_Log);
UClueSection* section;
if(!CollectedClueSections.Contains(ClueLocation))
{
section = CreateWidget<UClueSection>(GetOwningPlayer(), ClueSectionClass);
CollectedClueSections.Add(ClueLocation, section);
}
else
{
section = CollectedClueSections[ClueLocation];
}
if(section) section->SetSectionSize(SectionSize);
}
The error I am getting:
/Game/CBP/CBP_PlayerCharacter.CBP_PlayerCharacter_C.ExecuteUbergraph_CBP_PlayerCharacter
/Game/CBP/CBP_PlayerCharacter.CBP_PlayerCharacter_C.Add HUD
LogStats: FPlatformStackWalk::StackWalkAndDump - 0.592 s
LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: Lhs.CurrentNum == Lhs.InitialNum [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Containers\Array.h] [Line: 237]
LogOutputDevice: Error: Array has changed during ranged-for iteration!
LogOutputDevice: Error: Stack:
LogOutputDevice: Error: [Callstack] 0x00007fffeb4f12b8 UnrealEditor-UMG.dll!UScrollBox::RebuildWidget() [D:\build\++UE5\Sync\Engine\Source\Runtime\UMG\Private\Components\ScrollBox.cpp:144]
I’ve isolate the error to the GetParent->AddChild(section.Value) line, but I’m still unsure why that is giving me an error. And to make it more confusing, the error only occurs on the first playthrough each time I open the editor