UE4 crashes opening blueprint with C++ component

Hello,

I have this C++ called UPLLoginHandler derived from UPLPhotonBaseHandler which also derive from UActorComponent

The problem is in blueprint, if I attach ULoginHandler as an actor component, and if I close the blueprint editor and reopen it again, it will crashes the editor. I don’t have any problem with UBaseHandler attached as component, I can reopen it as many times as I want.

here is code for UPLLoginHandler.h

UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class PHOTONLEARN_API UPLLoginHandler : public UPLPhotonBaseHandler
{
	GENERATED_BODY()
	
public:
	UPLLoginHandler(const FObjectInitializer& ObjectInitializer);

	virtual void InitializeComponent();
	virtual void HandleOnOperationResponse(const OperationResponse& operationReponse);

	virtual void HandleOnStatusChanged(int statusCode) override;

	virtual void HandleOnEvent(const EventData& eventData) override;
	virtual void HandleDebugReturn(int debugLevel, const JString& string) override;

	//UFUNCTION(BlueprintNativeEvent, Category = "Photon")
	//	void HandleOnStatusChangedBlueprint(int statusCode);
	//virtual void HandleOnStatusChangedBlueprint_Implementation(int statusCode);

	UPROPERTY(BlueprintReadWrite)
		UPLGameInstance* PLGameInstance;

	//UPROPERTY(BlueprintAssignable, Category = "Photon")
	//	FHandleOnStatusChangedDelegate OnStatusChanged;
};

and for UPLPhotonBaseHandler.h

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FHandleOnStatusChangedDelegate, int, StatusCode);

UCLASS( ClassGroup = (Custom), meta = (BlueprintSpawnableComponent))
class PHOTONLEARN_API UPLPhotonBaseHandler : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UPLPhotonBaseHandler(const FObjectInitializer& ObjectInitializer);

	//virtual void BeginPlay() override;
	//virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	virtual void HandleDebugReturn(int debugLevel, const JString & string);
	virtual void HandleOnOperationResponse(const OperationResponse& operationResponse);
	virtual void HandleOnStatusChanged(int statusCode);
	virtual void HandleOnEvent(const EventData & eventData);

	UPROPERTY(BlueprintAssignable, Category = "Photon")
		FHandleOnStatusChangedDelegate OnStatusChanged;	
	
};

Hey Andi Winata,

I do not know what the following references are for and therefore, can’t replicate your issue completely:

[UPLLoginHandler.h]

  • OperationResponse
  • EventData
  • JString
  • UPLGameInstance

[UPLPhotonBaseHandler.h]

  • FHandleOnStatusChangedDelegate

The best I can do to test your issue is to make a class that inherits from AActorComponent and then another that inherits from that, which doesn’t crash.

If you are able to provide more information on what these references are for and the code for them, I can look into the issue further.

It would also help to include the crash log.

Hi! Thanks for the reply

I’m trying to integrate Photon with UE4.
so

  • OperationResponse, EventData, and JString are Photon native C++ classes from Photon SDK
  • UPLGameInstance is derived from UGameInstance
  • FHandleOnStatusChangedDelegate is dynamic multicast delegate
    which would be subscribed by events in blueprint and that delegate will be called on HandleOnStatusChanged(int statusCode) override;.

The reason for this is so I can expose the functions to blueprint in case any of the functions is called

So yeah unfortunately some of them are not derived from the AActorComponent, but then again it is fine for the UPLPhotonBaseHandler.h, only cause problem with its children.

I’ll give the crash log later on

I notice the InitializeComponent declaration on line 9 in your LoginHandler. Add the override keyword and ensure that you call Super::InitializeComponent() in the method implementation.

I added the override keyword with call to parent’s function and still giving same crash.

Is this the right log?

link text

Hey Shohei,

Because Photon is an external plugin, we don’t have any internal documentation or support for it. I can suggest asking the Photon developers about the issue.