diff options
| author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2018-09-12 02:41:54 +0200 |
|---|---|---|
| committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2018-09-12 03:24:08 +0200 |
| commit | e558e1ec09aa27852426bbd24dfa21e9b60cfbfc (patch) | |
| tree | f9a6b7391f7bf047526ab5cbac584b647a68227c /modules/mono/glue/cs_files/Object.base.cs | |
| parent | 61426464ea28f82f0c340572caafeb6aaaad4c91 (diff) | |
| download | redot-engine-e558e1ec09aa27852426bbd24dfa21e9b60cfbfc.tar.gz | |
Fix/workaround for issue #21667
When a Reference managed instance is garbage collected and its finalizer is called, it could happen that the native instance is referenced once again before the finalizer can unreference and memdelete it. The workaround is to create a new managed instance when this happens (at least for now).
Diffstat (limited to 'modules/mono/glue/cs_files/Object.base.cs')
| -rw-r--r-- | modules/mono/glue/cs_files/Object.base.cs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/mono/glue/cs_files/Object.base.cs b/modules/mono/glue/cs_files/Object.base.cs index 5d62d0b335..30490a715f 100644 --- a/modules/mono/glue/cs_files/Object.base.cs +++ b/modules/mono/glue/cs_files/Object.base.cs @@ -54,7 +54,11 @@ namespace Godot if (memoryOwn) { memoryOwn = false; - godot_icall_Object_Dtor(this, ptr); + godot_icall_Reference_Disposed(this, ptr, !disposing); + } + else + { + godot_icall_Object_Disposed(this, ptr); } this.ptr = IntPtr.Zero; @@ -72,7 +76,10 @@ namespace Godot internal extern static IntPtr godot_icall_Object_Ctor(Object obj); [MethodImpl(MethodImplOptions.InternalCall)] - internal extern static void godot_icall_Object_Dtor(object obj, IntPtr ptr); + internal extern static void godot_icall_Object_Disposed(Object obj, IntPtr ptr); + + [MethodImpl(MethodImplOptions.InternalCall)] + internal extern static void godot_icall_Reference_Disposed(Object obj, IntPtr ptr, bool isFinalizer); // Used by the generated API [MethodImpl(MethodImplOptions.InternalCall)] |
