diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2017-12-31 22:37:57 +0100 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2018-01-01 03:05:13 +0100 |
commit | b271aa48e4e0af3d9abb998ac9c03eae3b65825a (patch) | |
tree | bfb6702c16a72a476d7969283e8f8e51da9470fd /modules/mono/csharp_script.h | |
parent | e350a56efd8d307a989414b474960468a67550d1 (diff) | |
download | redot-engine-b271aa48e4e0af3d9abb998ac9c03eae3b65825a.tar.gz |
Mono: Script lifetime fixes
- alloc_language_binding: Use strong GC handle as well for references. Fixes #15138
- Set the native instance field of Godot.Object to IntPtr.Zero when it's freed.
- Create weak handles without tracking resurrection (that was causing trouble). This means we have to call notification predelete before queueing a native Object for deletion, and use the MonoObject* passed by the finalizer because the weak GC handle target will return NULL at this point.
Diffstat (limited to 'modules/mono/csharp_script.h')
-rw-r--r-- | modules/mono/csharp_script.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h index 255665b495..1a07cf6835 100644 --- a/modules/mono/csharp_script.h +++ b/modules/mono/csharp_script.h @@ -167,7 +167,7 @@ class CSharpInstance : public ScriptInstance { bool base_ref; bool ref_dying; - void _ml_call_reversed(GDMonoClass *klass, const StringName &p_method, const Variant **p_args, int p_argcount); + void _ml_call_reversed(MonoObject *p_mono_object, GDMonoClass *klass, const StringName &p_method, const Variant **p_args, int p_argcount); void _reference_owner_unsafe(); void _unreference_owner_unsafe(); @@ -176,6 +176,8 @@ class CSharpInstance : public ScriptInstance { friend void GDMonoInternals::tie_managed_to_unmanaged(MonoObject *, Object *); static CSharpInstance *create_for_managed_type(Object *p_owner, CSharpScript *p_script, const Ref<MonoGCHandle> &p_gchandle); + void _call_multilevel(MonoObject *p_mono_object, const StringName &p_method, const Variant **p_args, int p_argcount); + public: MonoObject *get_mono_object() const; @@ -192,13 +194,14 @@ public: void mono_object_disposed(); - void refcount_incremented(); - bool refcount_decremented(); + virtual void refcount_incremented(); + virtual bool refcount_decremented(); - RPCMode get_rpc_mode(const StringName &p_method) const; - RPCMode get_rset_mode(const StringName &p_variable) const; + virtual RPCMode get_rpc_mode(const StringName &p_method) const; + virtual RPCMode get_rset_mode(const StringName &p_variable) const; virtual void notification(int p_notification); + void call_notification_no_check(MonoObject *p_mono_object, int p_notification); virtual Ref<Script> get_script() const; @@ -215,6 +218,8 @@ class CSharpLanguage : public ScriptLanguage { static CSharpLanguage *singleton; + bool finalizing; + GDMono *gdmono; SelfList<CSharpScript>::List script_list; |