Hi, I’d like to know if this is a bug, an expected behaviour or if I’m doing something wrong. So, first, I declare a dynamic delegate inside my class:
DECLARE_DYNAMIC_DELEGATE_OneParam(FOnMapReceivedSignature, UTexture2D*, MapTexture);
Then, I declare a method that receives this delegate as a parameter:
UFUNCTION(BlueprintCallable)
bool RequestMap(const FVector2D Center, const float MinRadius, const int32 TextureWidth, const int32 TextureHeight, const FOnMapReceivedSignature& OnMapReceived);
On the RequestMap method, I then capture the delegate inside a lambda, by doing this:
Request->OnProcessRequestComplete().BindLambda(
[this, &OnMapReceived](FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
/* the lambda code */
OnMapReceived.ExecuteIfBound(MapTexture);
}
I’m calling the method RequestMap from a blueprint. According to my debugging, right after entering the method, the delegate is bound, as expected. However, inside the lambda, it’s not anymore, i.e., the captured reference somehow becomes unboud. I have confirmed this by creating an attribute inside my class, holding the delegate on that attribute and then calling that attribute from the lambda, which works.
I’ve tried capturing the delegate either by reference and by value and, in both cases, it becomes unboud. Is that normal?
Thanks in advance!