Crash on accessing a TMap
I'm writing a plugin which connects NavVolume actors together so that they can be navigated between. To do this, I'm making a navigator actor class, which has a TMap with the NavVolume-NavVolume connections (as UObject) as the Key and the cost to travel the connection as the TMap Element.
My project is set up such that I have:
All this seems to work as I wanted, and once I've added a number of connections to the TMap, I can see them represented by some debug lines between the volumes in the editor.
If I then want to change the TMap, I call reset on it first, because I want to start with a blank TMap. However, then when I call .Add() to add my new connection to the TMap, I get a
I have a debug log function which prints out each key and element of the TMap (via a
Am I not using .Reset correctly?
asked Aug 04 '16 at 07:38 PM in C++ Programming
From the TMap documentation:
So when you try to iterate over your reset TMap, you are deferencing a null pointer (the key). This should account for the second error you listed. To fix this, use Empty() instead. You can pass an optional parameter to it that lets you set slack for your TMap to avoid reallocation. See the documentation linked above.
As for your first error, it might have something to do with the invalid memory from Reset() as well. See if Empty() fixes that problem too.
EDIT: this was only part of the solution. See continuing conversation below.
That error means that you are trying to access a nullptr, that is a pointer that has not been set to anything. As such you have to check if edgeMap is not null before using it. Then you have to find out how it got there as a nullptr.
answered Aug 04 '16 at 07:57 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here