Hot Reload Blueprint Issues in 4.17

Hi there! We had some problems with Hot Reload reliably being broken in our project on 4.17, unfortunately I didn’t see this particular question until I’d tracked down the problem to being with the Function delegates like Michaël did in [Hot Reload errors since upgrade to 4.8.1 - Blueprint - Unreal Engine Forums][1]. I’ve implemented his workaround of moving the delegates outside of the class declarations which does get around the problem.

But I do have some more information in case a more robust fix than just forbidding delegates in the class declarations is wanted.

The problem is that nearly any code changes in a module will cause the module’s fixup Z_Construct_UPackage__Script_ModuleName function to be called. For example, any struct or enum auto-generated RegisterFn() will trigger the fixup from UObjectLoadAllCompiledInStructs(). The module fixup function recreates all of the delegate functions, which breaks the linked list of UFunctions in the class and will cause blueprints to not compile until restarting the editor. Calling the class fixup (Z_Construct_UClass_AShooterCharacter) seems like it would recreate the list… but that doesn’t happen.

I made some quick changes to the ShooterGame which can demonstrate the problem, essentially it’s a matter of getting some UFunctions in the linked list after the Delegate which will be wiped out, I modified ShooterCharacter.h:

    bool IsTargeting() const;
    //Begin Insert

	UFUNCTION(BlueprintCallable)
	void LlamaRunning();

	UFUNCTION(BlueprintCallable)
	void LlamaJumping();

	UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
	void LlamaRagdoll();

	DECLARE_DYNAMIC_MULTICAST_DELEGATE(FLlamaTamed);

	UPROPERTY(BlueprintCallable, BlueprintAssignable)
	FLlamaTamed OnLlamaTamed;

	UFUNCTION(BlueprintCallable)
	void LlamaSpitting();
    //End insert

With empty implementations in ShooterCharacter.cpp.

Next create a blueprint on the BotPawn which references some functions created in the ShooterCharacter.h, and then do a hot-reload of the Shooter Module from the editor (I was modifying ShooterBot.cpp to get it to trigger):

Refreshing all nodes will show the extent of the damage:

If it does not break the chain, you can inspect the linked list of the AShooterCharacter to see where the delegate is and the list has been broken to try and add additional functions that will break in there.

I’m not familiar enough with the quirks of the system to know what a good fix would be, some bookkeeping either with ordering the delegates in the list or remembering which classes need to be fixed up later seem like they could work.