Merge pull request #158 from antianno/fix_glib_value_variant_cast

Handle NULL in GLib.Value -> GLib.Variant cast operator
This commit is contained in:
Harry 2020-05-17 21:59:52 +02:00 committed by GitHub
commit e2c2ab1cf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -275,9 +275,10 @@ namespace GLib {
return GLib.Opaque.GetOpaque (g_value_get_boxed (ref val), (Type) new GType (val.type), false); return GLib.Opaque.GetOpaque (g_value_get_boxed (ref val), (Type) new GType (val.type), false);
} }
public static explicit operator GLib.Variant (Value Val) public static explicit operator GLib.Variant (Value val)
{ {
return new Variant (g_value_get_variant (ref Val)); IntPtr native_variant = g_value_get_variant (ref val);
return native_variant == IntPtr.Zero ? null : new Variant (native_variant);
} }
public static explicit operator GLib.VariantType (Value val) public static explicit operator GLib.VariantType (Value val)