Description

Much like [Link Removed] (which I'm backing down on my by design claim), there is an issue where if you previously referenced a component that no longer exists, the correct instanced subobject is lost.

In this case the issue is that in UActorComponent::PostInitProperties() the old component is marked pending kill as there is no archetype for it in the parent class. This is a slight variation on [Link Removed] where the class for the previously saved component is gone and so the serialized object is null overwriting the constructor instanced version.

In both cases, the core of the issue is that the constructor and subobject instancing runs before serialization at which point a null/invalid object overwrites the property even though it should be discarded.

Turtles should fix this, but not necessarily soon.

Steps to Reproduce

Add the following class

UCLASS(BlueprintType)
class AMyClassTest : public AActor
{
	GENERATED_BODY()

public:

	AMyClassTest();

	UPROPERTY(BlueprintReadWrite, VisibleDefaultsOnly)
	UStaticMeshComponent* TheComponent = nullptr;

};

In the cpp implement the constructor as so

AMyClassTest::AMyClassTest()
{
	RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
	TheComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("TheComponent"));
	TheComponent->SetupAttachment(RootComponent);
}

Compile and run the editor, create a blueprint from MyClassTest
Compile the blueprint, save, and close the editor

In the constructor change TEXT("TheComponent") to TEXT("MyComponent")

Compile and run the editor and open your Blueprint
Click on TheComponent

Result: Details panel is blank
Expected: Properties for MyComponent should be present

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-115124 in the post.

2
Login to Vote

Backlogged
CreatedMay 7, 2021
UpdatedNov 29, 2023
View Jira Issue