BindUObject looks thread-unsafe?

Sometimes, Calling ExecuteIfBound failed because of UObject’s RF_Unreachable flag in GarbageCollecting Process.

If Other thread called Delegate’s ExecuteIfBound function Between Set and Clear RF_Unreachable, TBaseUObjectMethodDelegateInstance’s
FORCEINLINE const void* GetRawUserObjectInternal( ) const
{
return UserObject.Get();
}
function returned NULL. (UserObject is WeakObjectPtr, so if RF_Unreachable, return NULL)

If BindUObject is used, UObject binded Delegate need to be RF_RootSet?

Because it’s only a weak pointer, if the object is not RF_RootSet, there’s also the possibility that the object will be garbage collected (deleted!) in the middle of your delegate callback! I would recommend not running any code that interacts with UObjects during GC.

UObjects aren’t really safe to use from any thread other than the main thread.

Hi,

We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.

Thanks!

No Problem!

Thanks!