Hey Peeps,
So I am working with TLinkedList as the topic describes. I have hit a roadblock. I understand how Linked Lists work just fine, which is not the problem. I have the following:
for( auto stage : QuestStages )
{
UQuestStage* newStage = NewObject<UQuestStage>(this->GetOuter(), stage->GetFName(), RF_NoFlags, stage->GetDefaultObject(), true);
UE_LOG(QuestSystem, Warning, TEXT("newStage Name : %s"), *newStage->Name);
if( !newStage )
{
UE_LOG(QuestSystem, Warning, TEXT("Quest Stage Object not valid!"));
return;
}
TLinkedList<UQuestStage*> LinkList = TLinkedList<UQuestStage*>(newStage);
if( !LinkedQuestStages.GetPrevLink() || !LinkedQuestStages.IsLinked() )
{
LinkedQuestStages = TLinkedList<UQuestStage*>(newStage);
LinkedQuestStagesHead = &LinkedQuestStages;
LinkList.LinkHead(LinkedQuestStagesHead);
continue;
}
else
{
if( LinkedQuestStagesHead->GetPrevLink() || LinkedQuestStages.GetPrevLink() )
{
LinkList.LinkAfter(*LinkedQuestStagesHead->GetPrevLink());
}
}
}
for( auto Node : LinkedQuestStages)
{
UE_LOG(QuestSystem, Warning, TEXT("Stage Name: %s"), *Node->Name);
}
}
For some reason, after the first loop, the LinkedQuestStagesHead and LinkedQuestStages GetPrevLink() and GetNextLink() are NULL and I am not sure as to why. I highly doubt it’s a garbage collection issue.
QuestStages is a
TArray<TSubclassOf<UQuestStage>>
Any ideas?