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.
This commit is contained in:
Bertrand Lorentz 2012-11-17 17:34:50 +01:00
parent 05fb2e2f3a
commit 306f422c38
2 changed files with 1 additions and 8 deletions

View File

@ -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) {

View File

@ -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; }
}
}
}