diff --git a/ChangeLog b/ChangeLog index c2b592614..6b8023946 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-08 Marek Habersack + + * generator/InterfaceGen.cs: added a check for null obj in the + generated GetObject method. + 2008-04-04 Mike Kestner * atk/Atk.metadata: add a few more owned refs. diff --git a/generator/InterfaceGen.cs b/generator/InterfaceGen.cs index bbc79342d..e63fcd50e 100644 --- a/generator/InterfaceGen.cs +++ b/generator/InterfaceGen.cs @@ -209,7 +209,9 @@ namespace GtkSharp.Generation { sw.WriteLine ("\t\tpublic static " + Name + " GetObject (IntPtr handle, bool owned)"); sw.WriteLine ("\t\t{"); sw.WriteLine ("\t\t\tGLib.Object obj = GLib.Object.GetObject (handle, owned);"); - sw.WriteLine ("\t\t\tif (obj is " + Name + "Implementor)"); + sw.WriteLine ("\t\t\tif (obj == null)"); + sw.WriteLine ("\t\t\t\treturn null;"); + sw.WriteLine ("\t\t\telse if (obj is " + Name + "Implementor)"); sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj as {0}Implementor);", Name); sw.WriteLine ("\t\t\telse if (obj as " + Name + " == null)"); sw.WriteLine ("\t\t\t\treturn new {0}Adapter (obj.Handle);", Name);