x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

TAssetSubclassOf pathname reset during garbage collection?

I'm using a TArray of USTRUCTs, each with a TAssetSubclassOf UPROPERTY field called AssetPtr, like so:

 UPROPERTY(EditAnywhere)
 TAssetSubclassOf<UQuestAsset> AssetPtr;

I go through each and call AssetPtr.LoadSynchronous() to process the referenced asset and load it into memory.

As it turns out, TAssetSubclassOf use weak pointers underneath the surface, so it makes sense that the referenced assets might get unloaded at some point.

But what seems odd is that when the WeakPtr is set to null, I also notice that the ObjectID and AssetLongPathname members within TAssetSubclassOf are reset to empty as well.

When I made a separate TAssetSubclassOf field in the struct that was not a UPROPERTY, I got these results:

 TAssetSubclassOf<UQuestAsset> AssetPtrNotUProperty; // stale pointer, but valid AssetLongPathname
 
 UPROPERTY(EditAnywhere)
 TAssetSubclassOf<UQuestAsset> AssetPtr; // stale pointer and empty AssetLongPathname

So though the weak pointer was stale in the non-UPROPERTY version, the asset path information was preserved.

I'm guessing that the distinction is that garbage collection processed the UPROPERTY version of TAssetSubclassOf and not the other. But is it intentional for FAssetPtrs to lose the asset pathname information when their underlying weak pointers are null, or is that a bug? Am I misuing TAssetSubclassOf somehow?

Product Version: UE 4.16
Tags:
more ▼

asked Jan 12 '18 at 02:07 AM in C++ Programming

avatar image

edward.wang
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question