Hello!
I’m use in my class variable:
TSharedPtr< FSlateDynamicImageBrush> * Icon;
for load dynamically from http my photo.
Until now, everything work well. I’m start new project for mobiles for convert my game to them. When adapt my old working code for http I’m shock when my photos disappers after 30-120 seconds. After a one day searching I discovered is garbage collector release it. So:
-
I cannot set UPROPERTY() to my Icon to prevent garbage collector, because is not UObject.
-
I cannot set Icon->AddToRoot() to my Icon to prevent garbage collector, because it is a method of UObject.
-
I create class FGCPreventer which inherited from FGCObject. Inside this class I create my
TSharedPtr< FSlateDynamicImageBrush> * Icon;
and create additional (I read on on forum that creating UObject inside struct/class where is our object, prevent garbage collector to all class/struct members):
UPROPERTY()
UTextBlock * FakeTxt;
and of course after creating my class instance, create FakeTxT object and set AddToRoot() like this:
GCIcon = new FGCPreventer();
GCIcon->FakeTxt = NewObject< UTextBlock> (UTextBlock::StaticClass());
GCIcon->FakeTxt->AddToRoot();
And I use my GCIcon->Icon like before. But without any success Still until 30-120 second I see empty brushes in editor.
The question in brief:
How to force prevent garbage collector to release non-uobject member:
TSharedPtr< FSlateDynamicImageBrush> * Icon;
of class inherited from UBlueprintFunctionLibrary.