[4.6.1] TWeakObjectPtr loses references to instances when referenced blueprint is compiled

If you have a property use TWeakObjectPtr to another object that is subclasses with a blueprint, then any references to instances of that blueprint will be cleared when you compile that blueprint. The references aren’t lost if you use normal pointers to reference the other objects, but those will be strong references. Since strong references will keep instances alive, that may not be desired.

Here’s a simple repro:

  1. Create a c++ class called AMyFirstActor and AMySecondActor.
  2. In AMyFirstActor make a UPROPERTY of a TWeakObjectPtr.
  3. Make a blueprint derived from AMySecondActor called MySecondBlueprint.
  4. Add an instance of AMyFirstActor and MySecondBlueprint to a level.
  5. Set the property created in step 2 on the AMyFirstActor instance, set it to the instanceof MySecondBlueprint.
  6. Compile the MySecondBlueprint.
  7. Notice the reference created in step 5 is cleared to “None”.

Expected:
TWeakObjectPtr references are not cleared when the objects referenced have their blueprints compiled.

Hey CombatJack-

I was able to reproduce the lost reference in 4.6.1 however I also tested this on the 4.7 preview 8 and found this this has already been fixed (reference was not lost upon compiling the blueprint). This fix should be included with the final release of 4.7 as well.

Cheers

Hi, the bug is still present in 4.22.3

Still present in 4.25 as well

And still present in 4.26.

same 5.1
working with the ComponnetReference struct which uses TWeakObjectPtr