C++ Delegate Listeners Not Called in Design Time

Hi there.

I have found a very frustrating bug that prevents bound delegate listeners in C++ firing whilst in design time. However, blueprint listeners work as expected.

Steps to reproduce in a clean project:

  1. Create a new C++ game project (4.25.3)
  2. Add C++ actor class called “ContentManager”
  3. Add C++ actor class called “ActorBase”

Code for ContentManager.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ContentManager.generated.h"

UCLASS()
class DELEGATEUTILITYBUG_API AContentManager : public AActor
{
	GENERATED_BODY()

	//Delegate Signatures
	//------------------------------
	DECLARE_DYNAMIC_MULTICAST_DELEGATE(FSendMessage);

	//Delegate Handlers
	//------------------------------
public:
	UPROPERTY(BlueprintAssignable, Category = "Content Manager|Event Dispatchers")
	FSendMessage OnSendMessage;
	
	//Functions
	//------------------------------
public:	
	// Sets default values for this actor's properties
	AContentManager();

	UFUNCTION(BlueprintCallable, Category = "Content Manager|Behaviour")
	void SendMessageToObjects();


protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
};

Code for ContentManager.cpp

#include "ContentManager.h"

// Sets default values
AContentManager::AContentManager(){}

void AContentManager::SendMessageToObjects()
{
	UE_LOG(LogTemp, Warning, TEXT("Has bound objects %s. Number of bound objects %d"), OnSendMessage.IsBound() ? TEXT("TRUE") : TEXT("FALSE"), OnSendMessage.GetAllObjects().Num());
	OnSendMessage.Broadcast();
}

// Called when the game starts or when spawned
void AContentManager::BeginPlay()
{
	Super::BeginPlay();
	
}

Code for ActorBase.h

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ActorBase.generated.h"

//Class Definitions
class AContentManager;

UCLASS()
class DELEGATEUTILITYBUG_API AActorBase : public AActor
{
	GENERATED_BODY()
	
	//Variables / Properties
	//--------------------------
private:
	AContentManager* contentManager;

public:	
	// Sets default values for this actor's properties
	AActorBase();

	UFUNCTION(BlueprintCallable, Category = "ActorBase|Initialise")
	void Initialise(AContentManager * inContentManager);

	UFUNCTION(BlueprintCallable, Category = "ActorBase|Behaviour")
	void OnReceiveMessage();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;


};

Code for ActorBase.cpp

#include "ActorBase.h"
#include "ContentManager.h"

// Sets default values
AActorBase::AActorBase(){}

void AActorBase::Initialise(AContentManager* inContentManager)
{
	contentManager = inContentManager;

	if (IsValid(contentManager))
	{
		contentManager->OnSendMessage.AddDynamic(this, &AActorBase::OnReceiveMessage);
		UE_LOG(LogTemp, Log, TEXT("Actor base successfuly initialised"));
	}
}

void AActorBase::OnReceiveMessage()
{
	UE_LOG(LogTemp, Log, TEXT("%s has received the message"), *GetName());
}

// Called when the game starts or when spawned
void AActorBase::BeginPlay()
{
	Super::BeginPlay();
}
  1. In the editor, create an Editor Utility Blueprint called WBP_ContentTool
  2. Remove the canvas panel and add a button and a text widget as a child

  1. Add the following blueprint code to the buttons “OnClicked” event

  1. In the editor, right-click WBP_ContentTool and "Run Editor Utility Widget
  2. Click the button and notice in the logs, only the blueprints bound event was called.

  1. Now open the level blueprint
  2. Copy and paste the code from WBP_TestMap and execute from BeginPlay

**Be sure to replace the “Spawn Actor” function nodes to work at run time **

  1. Remove the ContentManger and ActorBase objects if they still exist in the world outliner
  2. Run the simulation. Note both delegate listeners were called.

Expected Result
Both listeners should have been outputted in the Editor blueprint.

I am really surprised that it is the C++ implementation that is broken and not the blueprint implementation.

Thank you for your time.

Kind regards

Alex

Hello,

We’ve made a switch to a new bug reporting method using a more structured form. Please visit the link below for more details and report the issue using the new Bug Submission Form. Feel free to continue to use this thread for community discussion around the issue.

Thanks

Hi .

Thanks for the update. I have submitted an official bug report.
I will keep this question open in case someone else experiences this issue.

Kind regards
Alex