From b271aa48e4e0af3d9abb998ac9c03eae3b65825a Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Sun, 31 Dec 2017 22:37:57 +0100 Subject: 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. --- modules/mono/mono_gc_handle.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'modules/mono/mono_gc_handle.cpp') diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp index 121392b3f8..d407aa6981 100644 --- a/modules/mono/mono_gc_handle.cpp +++ b/modules/mono/mono_gc_handle.cpp @@ -41,10 +41,7 @@ uint32_t MonoGCHandle::make_strong_handle(MonoObject *p_object) { uint32_t MonoGCHandle::make_weak_handle(MonoObject *p_object) { - return mono_gchandle_new_weakref( - p_object, - true /* track_resurrection: allows us to invoke _notification(NOTIFICATION_PREDELETE) while disposing */ - ); + return mono_gchandle_new_weakref(p_object, false); } Ref MonoGCHandle::create_strong(MonoObject *p_object) { -- cgit v1.2.3