generator: null check for handle (NativeStructGen)

Check Handle against IntPtr.Zero before marshalling.
This commit is contained in:
Stephan Sundermann 2013-07-11 12:58:05 +02:00 committed by Andrés G. Aragoneses
parent 29a900e51e
commit 33fd293b84

View file

@ -126,7 +126,8 @@ namespace GtkSharp.Generation
sw.WriteLine ("\t\tprivate void Update ()", QualifiedName);
sw.WriteLine ("\t\t{");
sw.WriteLine ("\t\t\tthis.managed_struct = ({0})Marshal.PtrToStructure (this.Handle, typeof({0}));", native_struct_name);
sw.WriteLine ("\t\t\tif (Handle != IntPtr.Zero)");
sw.WriteLine ("\t\t\t\tthis.managed_struct = ({0})Marshal.PtrToStructure (this.Handle, typeof ({0}));", native_struct_name);
sw.WriteLine ("\t\t}");
sw.WriteLine ();
}