Hello!
I just ran into an issue with delegates and thought it would be good to let you guys know.
So there is the “AddDynamic” macro which allows you to bind an object with a function to a delegate, which works just as expected when you do for example this:
MyDelegate.AddDynamic(this, &MyClass::TestFunction);
But now if you want to do that with a function pointer for example like this:
void MyClass::MyFunction(void (MyClass:: *FunctionPtr)())
{
MyDelegate.AddDynamic(this, FunctionPtr);
}
It will cause a crash with an error message which looks something like “FunctionPtr is not a member function of…”. The reason for this is that the AddDynamic macro uses the FuncName input to set the function name in the __Internal_AddDynamic function, so in this example it would call:
__Internal_AddDynamic(this, &MyClass::SomeFunction, TEXT("FunctionPtr"));
Of course you can do workarounds for this like adding the function name as a string parameter to your bind function and call __Internal_AddDynamic directly, but it would be awesome if there could be a better solution for this.