Component properties reset by blueprint compile

The description of this bug is going to sound bizare, but I’ve boiled it down to the simplest repro steps.

Repro steps

  1. create blueprint BugActor as simple Actor
  2. create blueprint BaseComponent as simple ActorComponent
  3. create blueprint BugComponent with BaseComponent as parent
  4. open BaseComponent and Add Variable of MyFlag boolean (click eye to expose variable)
  5. inside BaseComponent do AddCustomEvent of MyFunction leave it empty
  6. inside BaseComponent add PrintString node to BeginPlay
  7. open BugActor and Add Component of BugComponent
  8. drag BugComponent into BeginPlay graph and call MyFunction on it
  9. place instance of BugActor in the map
  10. select BugActor and in details BugComponent and toggle MyFlag [true]
  11. open BaseComponent and edit the PrintString text to modify blueprint
  12. click Compile button on the BaseComponent

Notice the map is immediately marked modified. If you select the BugActor the MyFlag will be reset to false.
The same will happen to any other properties on this component. If you remove any of the elements it behaves correctly. The call to MyFunction from the Actor seems to cause some dependency that triggers the reset. The component sub-class is also important for some reason.

The pattern is very common in our large project… and the consequence of randomly losing data have been causing a lot of pain.