From a7bebb15b178ef5c3ae1e24cc08451db0545dafe Mon Sep 17 00:00:00 2001 From: Christian Hoff Date: Tue, 21 Jul 2009 06:51:10 +0000 Subject: [PATCH] 2009-07-21 Christian Hoff * glib/GInterfaceAdapter.cs: Fix a leak related to GCHandles not being freed. Patch from Mike Kestner with a minor tweak by me. [Fixes #523306] svn path=/trunk/gtk-sharp/; revision=138263 --- glib/GInterfaceAdapter.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/glib/GInterfaceAdapter.cs b/glib/GInterfaceAdapter.cs index e44c9401c..d76be76a6 100644 --- a/glib/GInterfaceAdapter.cs +++ b/glib/GInterfaceAdapter.cs @@ -40,8 +40,6 @@ namespace GLib { protected GInterfaceAdapter () { - info.FinalizeHandler = new GInterfaceFinalizeHandler (Finalize); - info.Data = (IntPtr) GCHandle.Alloc (this); } protected GInterfaceInitHandler InitHandler { @@ -56,14 +54,11 @@ namespace GLib { internal GInterfaceInfo Info { get { + if (info.Data == IntPtr.Zero) + info.Data = (IntPtr) GCHandle.Alloc (this); + return info; } } - - void Finalize (IntPtr iface_ptr, IntPtr data) - { - GCHandle gch = (GCHandle) data; - gch.Free (); - } } }