From 11286d19c6ba784b77e1e09851ed9824e619beaf Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Tue, 15 Apr 2008 19:43:16 +0000 Subject: [PATCH] 2008-04-15 Mike Kestner * generator/ReturnValue.cs: use new GLib.Opaque.OwnedCopy for owned opaque return values. * glib/Opaque.cs: introduce OwnedCopy property to support returning owned opaque instances from native to managed callbacks. [Fixes #374641] svn path=/trunk/gtk-sharp/; revision=100762 --- ChangeLog | 8 ++++++++ generator/ReturnValue.cs | 2 ++ glib/Opaque.cs | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index 67836abf3..a9846cde8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-04-15 Mike Kestner + + * generator/ReturnValue.cs: use new GLib.Opaque.OwnedCopy for owned + opaque return values. + * glib/Opaque.cs: introduce OwnedCopy property to support returning + owned opaque instances from native to managed callbacks. + [Fixes #374641] + 2008-04-15 Mike Kestner * gtk/Gtk.metadata: hide GtkKey_ for manual impl. diff --git a/generator/ReturnValue.cs b/generator/ReturnValue.cs index 1636004f6..cb40ceb3f 100644 --- a/generator/ReturnValue.cs +++ b/generator/ReturnValue.cs @@ -150,6 +150,8 @@ namespace GtkSharp.Generation { return (IGen as IManualMarshaler).AllocNative (var); else if (IGen is ObjectGen && owned) return var + " == null ? IntPtr.Zero : " + var + ".OwnedHandle"; + else if (IGen is OpaqueGen && owned) + return var + " == null ? IntPtr.Zero : " + var + ".OwnedCopy"; else return IGen.ToNativeReturn (var); } diff --git a/glib/Opaque.cs b/glib/Opaque.cs index 357eacddc..4258d56b6 100644 --- a/glib/Opaque.cs +++ b/glib/Opaque.cs @@ -113,6 +113,14 @@ namespace GLib { } } + public IntPtr OwnedCopy { + get { + Opaque result = Copy (Handle); + result.Owned = false; + return result.Handle; + } + } + public bool Owned { get { return owned;