Download

Delegate with another delegate as a parameter = Unreal Header Generation Tool crash (BUG?)

Consider this example code

.h


#pragma once

#include "GameFramework/Actor.h"

#include "MyActor.generated.h"


DELARE_DYNAMIC_DELEGATE_OneParam(FRegularDelegate, int32, SomeArgument);
DELARE_DYNAMIC_DELEGATE_OneParam(FDelegateWithDelegateParam, FRegularDelegate const &, RegularDelegate);


UCLASS()
class MYPROJECT_API AMyActor : public AActor
{
GENERATED_BODY()

public:
	AMyActor();

};


If I try to compile and hotreload this from the editor all I get is the standard Windows crash notification telling me that Unreal Header Generation Tool has stopped working. There are no warnings or errors in the log. This is the callstack after attaching the debugger upon crash:


 	UnrealHeaderTool-CoreUObject.dll!UObjectBase::GetFName() Line 101	C++
 	UnrealHeaderTool-CoreUObject.dll!UObjectBaseUtility::GetName() Line 207	C++
 	UnrealHeaderTool-CoreUObject.dll!UDelegateProperty::GetCPPType(FString * ExtendedTypeText=0x000000000ed277e0, unsigned int CPPExportFlags=2) Line 77	C++
>	UnrealHeaderTool-CoreUObject.dll!UProperty::ExportCppDeclaration(FOutputDevice & Out={...}, EExportedDeclaration::Type DeclarationType=Parameter, const wchar_t * ArrayDimOverride=0x0000000000000000, unsigned int AdditionalExportCPPFlags=0, bool bSkipParameterName=false) Line 463	C++
 	UnrealHeaderTool.exe!FNativeClassHeaderGenerator::ExportNativeFunctionHeader(const FFuncInfo & FunctionData, FStringOutputDevice & HeaderOutput={...}, EExportFunctionType::Type FunctionType=Event, EExportFunctionHeaderStyle::Type FunctionHeaderStyle=Declaration, const wchar_t * ExtraParam) Line 4026	C++
 	UnrealHeaderTool.exe!FNativeClassHeaderGenerator::ExportDelegateDefinitions(FUnrealSourceFile & SourceFile={...}, const TArray<UDelegateFunction *,FDefaultAllocator> & DelegateFunctions={...}, const bool bWrapperImplementationsOnly=false) Line 3129	C++
 	UnrealHeaderTool.exe!FNativeClassHeaderGenerator::ExportClassesFromSourceFileInner(FUnrealSourceFile & SourceFile={...}) Line 1926	C++
 	UnrealHeaderTool.exe!FNativeClassHeaderGenerator::ExportClassesFromSourceFileWrapper(FUnrealSourceFile & SourceFile={...}) Line 2512	C++
 	UnrealHeaderTool.exe!FNativeClassHeaderGenerator::ExportSourceFileHeaderRecursive(FClasses & AllClasses={...}, FUnrealSourceFile * SourceFile=0x0000000006708400, TSet<FUnrealSourceFile const *,DefaultKeyFuncs<FUnrealSourceFile const *,0>,FDefaultSetAllocator> & VisitedSet={...}, bool bCheckDependenciesOnly=false) Line 2656	C++
 	UnrealHeaderTool.exe!FNativeClassHeaderGenerator::ExportSourceFileHeader(FClasses & AllClasses={...}, FUnrealSourceFile * SourceFile=0x0000000006708400) Line 1861	C++
 	UnrealHeaderTool.exe!FNativeClassHeaderGenerator::FNativeClassHeaderGenerator(UPackage * InPackage=0x000000000670dd00, const TArray<FUnrealSourceFile *,FDefaultAllocator> & SourceFiles={...}, FClasses & AllClasses={...}, bool InAllowSaveExportedHeaders, bool bInExportVTableConstructors=88) Line 4799	C++
 	UnrealHeaderTool.exe!FHeaderParser::ExportNativeHeaders(UPackage * CurrentPackage=0x000000000670dd00, FClasses & AllClasses={...}, bool bAllowSaveExportedHeaders, bool bExportVTableConstructors) Line 6586	C++
 	UnrealHeaderTool.exe!FHeaderParser::ParseAllHeadersInside(FClasses & ModuleClasses={...}, FFeedbackContext * Warn=0x000007fed03bd640, UPackage * CurrentPackage=0x000000000670dd00, const FManifestModule & Module={...}, TArray<IScriptGeneratorPluginInterface *,FDefaultAllocator> & ScriptPlugins={...}, bool bExportVTableConstructors=true) Line 6755	C++
 	UnrealHeaderTool.exe!UnrealHeaderTool_Main(const FString & ModuleInfoFilename={...}) Line 5631	C++
 	UnrealHeaderTool.exe!wmain(int ArgC, wchar_t * * ArgV=0x000000000085cd90) Line 80	C++
 	[External Code]	


Within UDelegateProperty::GetCPPType SignatureFunction is a nullptr but GetName() is called on it.

Are delegates as parameters to other delegates not supported directly (a possible workaround for now is to wrap the delegate parameter in a USTRUCT first)?
Is this a bug or intended somehow? I assume it’s not simply fixed by making sure SignatureFunction is valid first (since it will be lacking that information in the generated/exported info)?

Thank you very much for any information.

Forgot to mention this occurs with Unreal Engine 4.9.1 could someone please confirm this still happens (or has been fixed) in newer versions?

Link to AnswerHub question for reference: https://answers.unrealengine.com/questions/392577/delegate-with-another-delegate-as-a-parameter-unre.html

Thanks again.