From 1a648517903a339d9bbe99b3064495587edef0ba Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Fri, 4 Apr 2008 05:00:42 +0000 Subject: [PATCH] 2008-04-04 Mike Kestner * atk/Object.custom: take out a ref on the return value of OnRefChild. Also add some null guarding and default to IntPtr.Zero on exceptions. svn path=/trunk/gtk-sharp/; revision=99826 --- ChangeLog | 6 ++++++ atk/Object.custom | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3922a0f2..f224e53e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-04-04 Mike Kestner + + * atk/Object.custom: take out a ref on the return value of + OnRefChild. Also add some null guarding and default to IntPtr.Zero + on exceptions. + 2008-04-01 Mike Kestner * generator/InterfaceGen.cs: support "generic" interface diff --git a/atk/Object.custom b/atk/Object.custom index 47bcbd976..aec50e0ee 100644 --- a/atk/Object.custom +++ b/atk/Object.custom @@ -61,16 +61,22 @@ static RefChildDelegate RefChildCallback; + [DllImport("libgobject-2.0-0.dll")] + static extern IntPtr g_object_ref (IntPtr handle); + static IntPtr RefChild_cb (IntPtr raw, int i) { try { Atk.Object obj = GLib.Object.GetObject (raw, false) as Atk.Object; - return obj.OnRefChild(i).Handle; + Atk.Object child = obj.OnRefChild (i); + if (child != null) + g_object_ref (child.Handle); + return child == null ? IntPtr.Zero : child.Handle; } catch (Exception e) { GLib.ExceptionManager.RaiseUnhandledException (e, false); } - return GLib.GType.Invalid.Val; + return IntPtr.Zero; }