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.
This commit is contained in:
parent
1fab57eeac
commit
280087e431
1 changed files with 4 additions and 0 deletions
|
@ -576,6 +576,10 @@ namespace GLib {
|
||||||
if (GType.Is (type, GType.Boxed) && !(val is IWrapper)) {
|
if (GType.Is (type, GType.Boxed) && !(val is IWrapper)) {
|
||||||
MethodInfo mi = val.GetType ().GetMethod ("Update", BindingFlags.NonPublic | BindingFlags.Instance);
|
MethodInfo mi = val.GetType ().GetMethod ("Update", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
IntPtr boxed_ptr = g_value_get_boxed (ref this);
|
IntPtr boxed_ptr = g_value_get_boxed (ref this);
|
||||||
|
|
||||||
|
if (mi == null && !val.GetType ().IsDefined (typeof(StructLayoutAttribute), false))
|
||||||
|
return;
|
||||||
|
|
||||||
if (mi == null)
|
if (mi == null)
|
||||||
Marshal.StructureToPtr (val, boxed_ptr, false);
|
Marshal.StructureToPtr (val, boxed_ptr, false);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue