From 306f422c38636d89a36b99290bb8c4f95dbd087f Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Sat, 17 Nov 2012 17:34:50 +0100 Subject: [PATCH] Fix a crash during initialization of interfaces (bxc#8447) GInterfaceInfo.Data was automatically set to be a GCHandle on the interface adapter. But the generated GInterfaceInitHandlers were not using it, just free'ing it. But for the GInterface property support, the Data field is now used to pass the class pointer, so casting it to a GCHandle to free it would cause an exception. We now don't assume anything about GInterfaceInfo.Data. --- generator/InterfaceGen.cs | 2 -- glib/GInterfaceAdapter.cs | 7 +------ 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index cb6d1acb1..8f979f7b2 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -114,8 +114,6 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\t\tnative_iface." + vm.Name + " = iface." + vm.Name + ";"); } sw.WriteLine ("\t\t\tMarshal.StructureToPtr (native_iface, ifaceptr, false);"); - sw.WriteLine ("\t\t\tGCHandle gch = (GCHandle) data;"); - sw.WriteLine ("\t\t\tgch.Free ();"); } foreach (Property prop in Properties.Values) { diff --git a/glib/GInterfaceAdapter.cs b/glib/GInterfaceAdapter.cs index 7b3c60064..ab71f6829 100644 --- a/glib/GInterfaceAdapter.cs +++ b/glib/GInterfaceAdapter.cs @@ -55,12 +55,7 @@ namespace GLib { public abstract IntPtr Handle { get; } internal GInterfaceInfo Info { - get { - if (info.Data == IntPtr.Zero) - info.Data = (IntPtr) GCHandle.Alloc (this); - - return info; - } + get { return info; } } } }