From cff3617dd215f703b1ec3ef25883a36744c011d7 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Mon, 4 May 2020 11:08:35 +0200 Subject: [PATCH] Convert Runtime.Dispose to use GCHandle. --- runtime/delegates.t4 | 2 +- src/ObjCRuntime/Runtime.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/runtime/delegates.t4 b/runtime/delegates.t4 index 61fa35d93a..7ab12fd241 100644 --- a/runtime/delegates.t4 +++ b/runtime/delegates.t4 @@ -188,7 +188,7 @@ }, new XDelegate ("void", "void", "xamarin_dispose", - "MonoObject *", "IntPtr", "mobj" + "GCHandle->MonoObject*", "IntPtr", "mobj" ) { WrappedManagedFunction = "Dispose", OnlyDynamicUsage = false, diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index 2812410b25..76dc6681c0 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -712,9 +712,9 @@ namespace ObjCRuntime { return ObjectWrapper.Convert (GetNSObject (ptr, type, MissingCtorResolution.ThrowConstructor1NotFound, true, out created)); } - static void Dispose (IntPtr mobj) + static void Dispose (IntPtr gchandle) { - ((IDisposable) ObjectWrapper.Convert (mobj)).Dispose (); + ((IDisposable) GetGCHandleTarget (gchandle)).Dispose (); } static bool IsParameterTransient (IntPtr info, int parameter)