I am running into an issue where my Unreal editor is crashing every time I open one of my data assets. I have narrowed it down to non-transient properties inside an instanced class. I have created the smallest reproducible code that I can to demonstrate the issue that I am having.
Unreal version: 5.8
Let’s say we have the following Primary Data Asset defined:
UCLASS()
class PROJECTANNA_API UTestPrimaryDataAsset : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, Instanced, BlueprintReadOnly, Category = "ProjectAnna|Ability")
TObjectPtr<UTestDataClass> TestData;
};
This is a simple PDA with one instanced property, which points to an instance of UTestDataClass. UTestDataClass has just one property, which for now is set to Transient and points to an empty struct:
USTRUCT(BlueprintType)
struct FTestContext
{
GENERATED_BODY()
};
UCLASS()
class PROJECTANNA_API UTestDataClass : public UObject
{
GENERATED_BODY()
protected:
UPROPERTY(Transient, BlueprintReadOnly, Category = "ProjectAnna|Ability")
FTestContext TestContext;
};
In my editor I can create a Blueprint class that inherits from UTestDataClass, an a Data Asset based on UTestPrimaryDataAsset. Within my data asset I can select my blueprint class without any problems.
However, if I change the TestContext property in my UTestDataClass to use EditDefaultsOnly so that I can modify some values that I add in the struct, the editor crashes with a stack overflow exception.
LoginId:cc997b9f4ee850fbaf2083b768347622
EpicAccountId:d8fbaf95baad4e7f9923256f307f8681
Unhandled Exception: EXCEPTION_STACK_OVERFLOW
UnrealEditor_PropertyEditor
UnrealEditor_PropertyEditor
UnrealEditor_PropertyEditor
...
I have used a Primary Data Asset in the past but I cannot remember ever running into an issue like this. I have ran a number of experiments and the only way I can seem to use a struct like this, is to make it as Transient. I have the exact same issue if I use TSubclassOf, for example the following would also cause a stack overflow exception when opening a data asset:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "ProjectAnna|Ability")
TSubclassOf<AActor> TestActorClass;
To be clear I can use the above code if it exists on the Primary Data Asset class itself, but not within an instanced class.
I am clearly misunderstanding something to do with instanced classes and PDAs. Could anyone help me to understand why this is happening?