You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
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).
This commit is contained in:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user