Delegate with another delegate as a parameter = Unreal Header Generation Tool crash

Unreal Header (Generation) Tool crashes with the following code (Unreal Engine 4.9.1 built from GitHub source)

.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();

};

This is the callstack after attaching the debugger upon UHT crashing. Within UDelegateProperty::GetCPPType SignatureFunction is NULL but GetName() is called on it.

 	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]

Any information regarding this issue is appreciated.
Link to forum thread for reference

I have never seen anyone do this, so i am not sure if it is supported. Why do you need to pass another delegate?

Even if it’s not supported, it should give error insted of crashing, so it can be count as bug

Hey UnrealEverything-

I have submitted a bug report about UHT crashing when attempting to declare a delegate as part of another delegate’s parameter list (UE-28643).

Cheers

Doug Wilson

This has now been fixed and should be in the 4.11 release. While UHT should now generate the correct code and (importantly) not crash, I can’t say how well it is supported in the rest of the engine, e.g. Blueprints.

Steve

Awesome thank you very much. Another reason to look forward to 4.11 :slight_smile:

In the meantime I’m wrapping FRegularDelegate in a USTRUCT and use that struct as the parameter type of FDelegateWithDelegateParam. That should also work fine with Blueprints or is that a wrong assumption?