For some reason I this function keeps crashing on line 36 with the error “Assertion failed: Pair != NULL”. I’m not using pointers and I suspend the thread that uses PathQueue TMap.
void FPathfindingWorker::AddNewPath(int32 Key, TArray<FVector> Nodes, FVector start, FVector finish)
{
if (Thread)
{
Thread->Suspend(true);
PathQueue.Add(Key);
PathQueue[Key].Add("AllNodes");
PathQueue[Key].Add("OpenList");
PathQueue[Key].Add("ClosedList");
PathQueue[Key].Add("PathList");
for (FVector Entry : Nodes)
{
FString HashVector = Entry.ToCompactString();
NodeData data;
data.Location = Entry;
data.bStart = false;
data.bTarget = false;
data.bClosed = false;
data.bOpen = false;
data.Fx = 0;
data.Gx = 0;
data.Hx = 0;
data.Parent = Entry;
CompleteList.Add(Key, false);
if (finish.Equals(Entry))
{
data.bTarget = true;
}
if (start.Equals(Entry))
{
data.bStart = true;
PathQueue[Key]["ClosedList"].Add(HashVector, data);
}
else
{
PathQueue[Key]["AllNodes"].Add(HashVector, data); // crash
}
if (start.Equals(finish))
{
data.bClosed = true;
PathQueue[Key]["PathList"].Add(HashVector, data);
ProcessedPaths.Add(Key, PathQueue[Key]);
PathQueue.Remove(Key);
CompleteList[Key] = true;
}
}
Thread->Suspend(false);
}
}
Here is the declaration to PathQueue:
TMap<int32, TMap<FString, TMap<FString, NodeData>>> PathQueue;
I’m not sure if this is because of thread safety, unreal not supporting TMap inside TMaps, or something else.