Added Object.TryGetObject that gets wrapper only if already surfaced

This commit is contained in:
Michael Hutchinson 2012-09-19 19:41:04 -04:00 committed by Bertrand Lorentz
parent 3a044d6faf
commit d686a4d6aa

View file

@ -82,6 +82,19 @@ namespace GLib {
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void g_object_unref (IntPtr raw); static extern void g_object_unref (IntPtr raw);
public static Object TryGetObject (IntPtr o)
{
if (o == IntPtr.Zero)
return null;
ToggleRef tr = (ToggleRef) Objects[o];
if (tr != null) {
return tr.Target;
}
return null;
}
public static Object GetObject(IntPtr o, bool owned_ref) public static Object GetObject(IntPtr o, bool owned_ref)
{ {
if (o == IntPtr.Zero) if (o == IntPtr.Zero)