From dc7145103d54d05489cafffc047cc2dd06d391ba Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Fri, 6 Feb 2004 21:33:14 +0000 Subject: [PATCH] 2004-02-06 Mike Kestner * generator/Method.cs : for Opaque/Object retvals, if raw_ret is NULL, return null instead of an object with a NULL handle. svn path=/trunk/gtk-sharp/; revision=22847 --- ChangeLog | 5 +++++ generator/Method.cs | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85e2b2b68..b705c29a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-02-06 Mike Kestner + + * generator/Method.cs : for Opaque/Object retvals, if raw_ret is + NULL, return null instead of an object with a NULL handle. + 2004-02-06 Mike Kestner * glib/time_t_CustomMarshaler.cs : use TimeSpan.TotalSeconds, not diff --git a/generator/Method.cs b/generator/Method.cs index 03442c189..d551bdd6e 100644 --- a/generator/Method.cs +++ b/generator/Method.cs @@ -359,9 +359,11 @@ namespace GtkSharp.Generation { sw.WriteLine(cname + call + ";"); } else if (ret_igen is ObjectGen || ret_igen is OpaqueGen) { sw.WriteLine(m_ret + " raw_ret = " + cname + call + ";"); - sw.WriteLine(indent +"\t\t\t" + s_ret + " ret = " + table.FromNativeReturn(rettype, "raw_ret") + ";"); - if (table.IsOpaque (rettype)) - sw.WriteLine(indent + "\t\t\tif (ret == null) ret = new " + s_ret + "(raw_ret);"); + sw.WriteLine(indent +"\t\t\t" + s_ret + " ret;"); + sw.WriteLine(indent + "\t\t\tif (raw_ret == IntPtr.Zero)"); + sw.WriteLine(indent + "\t\t\t\tret = null;"); + sw.WriteLine(indent + "\t\t\telse"); + sw.WriteLine(indent +"\t\t\t\tret = " + table.FromNativeReturn(rettype, "raw_ret") + ";"); } else if (ret_igen is CustomMarshalerGen) { sw.WriteLine(s_ret + " ret = " + cname + call + ";"); } else {