Added Object.TryGetObject that gets wrapper only if already surfaced
This commit is contained in:
parent
3a044d6faf
commit
d686a4d6aa
1 changed files with 13 additions and 0 deletions
|
@ -82,6 +82,19 @@ namespace GLib {
|
|||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||
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)
|
||||
{
|
||||
if (o == IntPtr.Zero)
|
||||
|
|
Loading…
Reference in a new issue