Download

UE4 double linked list and queue does not work with UPROPERTY() macro

Hi everyone!

Could somebody explain why Unreal’s TDoubleLinkedList and TQueue (and maybe some other containers, I’m not sure) does not want to compile with UPROPERTY() macro?

Without macro all is OK. However, the TArray and TMap containers works as expected and could be used with UPROPERTY().

4.24.3.

Appreciate any thoughts.

UPROPERTY assumes that the following property supports ue4 reflection system, garbage collection, serialization, blueprints and many more. Unfortunatelly, not every container supports it. The only containers that can be UPROPERTies are TArray, TMap and TSet. There were days, in old versions of UE4 where TMap didn’t support UPROPERTY too. Maybe they will add support for Queues and other containers too.

THNX for reply! Is it means that I must use manual deletion in owner class ~Destructor() while using TDoubleLinkedList or some options with TSharedPtr? What is the best practice for memory management in a similar situation?

What are you storing in the TDoubleLinkedList, and what is the linked list held inside? As a normal member (not a UPROPERTY) the list and its contents will be cleaned up when the owner is destructed, the issue is the garbage collector can’t know the list or its contents exist for reference-counting purposes - this matters if you’re storing UObject pointers, directly or indirectly (inside stored structs). You also need to be aware that the linked list won’t be able to be “saved” automatically, since Unreal’s default serialization works through UProperties.