Elements in array of Instanced UObjects on a Blueprint Component attached to an Actor are cleared when the Component is recompiled

As the title describes, we’ve found a repro in 5.5 where the elements of a TArray of Instanced UObjects are unexpectedly set to None when a blueprint component is recompiled.

#pragma once

#include "Components/ActorComponent.h"
#include "XYZTestInstancedObjectsComponent.generated.h"

UCLASS(Blueprintable, BlueprintType, EditInlineNew)
class XYZGAME_API UXYZTestInstancedObject : public UObject
{
    GENERATED_BODY()
};

UCLASS(BlueprintType, Blueprintable, meta=(BlueprintSpawnableComponent))
class XYZGAME_API UXYZTestInstancedObjectsComponent : public UActorComponent
{
    GENERATED_BODY()

protected:
    UPROPERTY(EditDefaultsOnly, Instanced, NoClear)
    TArray<UXYZTestInstancedObject*> InstancedObjects;
};

Using the above code:

  1. Create an Actor
    1. BP_Test_Actor
  2. Create a Blueprint Component derived from UXYZTestInstancedObjectsComponent
    1. Comp_TestInstanceObjects
  3. Add Comp_TestInstanceObjects to BP_Test_Actor
  4. Add elements to the InstancedObjects array on the added component, set them to the base type UXYZTestInstancedObject
  5. Open the Comp_TestInstanceObjects blueprint and press Compile
  6. Observe that the array elements on the Comp_TestInstanceObjects attached to BP_Test_Actor have been set to None

In testing, we see that this appears to be fixed in 5.6, but we’re not looking to take that version yet, and are interested in finding the specific CLs we might be able to cherrypick. Any ideas?

Hi there! I believe CL 44220549 a.k.a. GitHub commit 5025b6d3b4cf7698c026b2d7facd614dc5c2e9f6 is what you’re looking for. This fix rolled out with UE 5.6.1 and adds fixing up references to reinstanced subobjects when their class got recompiled.