ManagedCallable: use delegate target instead of middleman when possible

If the delegate target is an Object, the connected signal will be registered in that object instead of the middleman. So when that object is destroyed, the signal will be properly disconnected.
This commit is contained in:
Patrick Dawson
2022-09-30 18:22:11 +02:00
parent e69b7083d4
commit 161f295f52
6 changed files with 13 additions and 8 deletions

View File

@ -40,6 +40,7 @@
class ManagedCallable : public CallableCustom {
friend class CSharpLanguage;
GCHandleIntPtr delegate_handle;
ObjectID object_id;
#ifdef GD_MONO_HOT_RELOAD
SelfList<ManagedCallable> self_instance = this;
@ -66,7 +67,7 @@ public:
void release_delegate_handle();
ManagedCallable(GCHandleIntPtr p_delegate_handle);
ManagedCallable(GCHandleIntPtr p_delegate_handle, ObjectID p_object_id);
~ManagedCallable();
};