Download

[Bug] Dynamic Delegate AddDynamic Macro Incorrectly Parses Function Name

When using the AddDynamic macro of a dynamic delegate, line breaks can cause the function name to be incorrectly parsed.

For instance:

[FONT=courier new]delegate->AddDynamic(this, &UMyClass::MyFunction)

works fine.

However,

[FONT=courier new]delegate->AddDynamic(this, &UMyClass::
MyFunction)

fails.

In the second case, the AddDynamic macro expansion retains the space between the :: and MyFunction, i.e. the macro sees the function as “&UMyClass:: MyFunction”. Eventually this is passed to GetTrimmedMemberFunctionName, which retains everything after the :: as the function name, including the extra space, i.e. " MyFunction" in this case.

The easiest fix would be to trim leading spaces in the function name when removing the “<Class>::” prefix.

Well the easiest fix really is to just remove the line-break :wink:

I feel like trimming the function name just adds unnecessary bulk to the GetTrimmedMemberFunctionName() function which will ultimately bloat the cost of this everywhere. String parsing isn’t all that cheap.