From 280087e4312b0cc437f130266e4201af23405265 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Sat, 21 Jun 2014 17:05:32 +0200 Subject: [PATCH] Value: Don't try to marshal if type has no StructLayout If the StructLayout is not set, StructureToPtr will throw an exception. In these cases the type is probably wrapped using a handle and thus needs no update. --- glib/Value.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glib/Value.cs b/glib/Value.cs index 6a98d2a2f..be45c5ca5 100644 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -576,6 +576,10 @@ namespace GLib { if (GType.Is (type, GType.Boxed) && !(val is IWrapper)) { MethodInfo mi = val.GetType ().GetMethod ("Update", BindingFlags.NonPublic | BindingFlags.Instance); IntPtr boxed_ptr = g_value_get_boxed (ref this); + + if (mi == null && !val.GetType ().IsDefined (typeof(StructLayoutAttribute), false)) + return; + if (mi == null) Marshal.StructureToPtr (val, boxed_ptr, false); else