From 1fab57eeacf714a6c82f76cb7c95be4ca960afec Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Sat, 21 Jun 2014 16:59:22 +0200 Subject: [PATCH] Value: First try to invoke a constructor with IntPtr, bool In Cairo there the default constructor does not take a ref to the native object making the object invalid when trying to access it. This commit changes the behaviour to search for another constructor that takes an owner variable which is set to false when invoked to indicate that the managed side should take a ref. --- glib/Value.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/glib/Value.cs b/glib/Value.cs index 3159e27e9..6a98d2a2f 100644 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -437,7 +437,11 @@ namespace GLib { if (mi != null) return mi.Invoke (null, new object[] {boxed_ptr}); - ConstructorInfo ci = t.GetConstructor (new Type[] { typeof(IntPtr) }); + ConstructorInfo ci = t.GetConstructor (new Type[] { typeof(IntPtr), typeof (bool) }); + if (ci != null) + return ci.Invoke (new object[] { boxed_ptr, false }); + + ci = t.GetConstructor (new Type[] { typeof(IntPtr) }); if (ci != null) return ci.Invoke (new object[] { boxed_ptr });