Type 8 of EGCReferenceType i[FONT=Helvetica Neue]s GCRT_AddTMapReferencedObjects
This made me realize that I recently added UPROPERTY to one of my TMap variables.
The one in question that caused the issue was:
TMap<UWidget*, UBaseNavigableMenuStructure*> NavigationMap;
UBaseNavigableMenuStructure has parent UObject.
I wanted to post here for double coverage as answerhub is a bit of a black hole. This seems like a legit bug. In fact… it was too legit to quit, until I removed UPROPERTY().
To my latest knowledge TMap isn’t supported as a UPROPERTY. To prevent TMap entries from being garbage collected, I believe an often used work around is to have a UPROPERTY TArray that stores a copy of the TMap entries.
Cheers Steve. I have a quick question relating to this.
Am I right in assuming that TMap now supports UObject referencing for UObject* keys as well as UObject* values?
If so, what are the ramifications (if any) of using a UObject*-keyed map as a UPROPERTY, given that the keys would presumably be set to null if the pointed-to object was garbage collected? In my experience map keys need to be unique and immutable. How is this dealt with?
I wondered the same thing pre-4.8 about a TMap< TWeakObjectPtr< UObject >, FSomeType >, which I had come across at places in the engine code.
Oh my god, I’ve been banging my head for days. I also use TMap in my UI navigation and my widgets is being garbage collected and crashes the game. Until now apparently is still a problem.
Using UE4.27.2 and the entries in a TMap are still getting garbage collected, even with UPROPERTY(). Unless there’s any more versions planned for UE4 I guess this will always be an issue.