diff --git a/ChangeLog b/ChangeLog index e892bf010..328cfd6d4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-05-13 Sebastian Dröge + + * glib/Value.cs: return int object value for GType.Enum values if + the explicit gtype is not found. [Fixes #503060] + 2009-05-13 Sebastian Dröge * glib/ValueArray.cs: use type specific PtrToStructure marshaling to diff --git a/glib/Value.cs b/glib/Value.cs index cfb431591..290d96ae7 100755 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -393,6 +393,20 @@ namespace GLib { this = (GLib.Value) parameters[0]; } + object ToEnum () + { + Type t = GType.LookupType (type); + + if (t == null) { + if (HoldsFlags) + return g_value_get_flags (ref this); + else + return g_value_get_enum (ref this); + } else { + return (Enum) this; + } + } + object ToBoxed () { IntPtr boxed_ptr = g_value_get_boxed (ref this); @@ -428,7 +442,7 @@ namespace GLib { return (ulong) this; else if (GType.Is (type, GType.Enum) || GType.Is (type, GType.Flags)) - return (Enum) this; + return ToEnum (); else if (type == GType.Float.Val) return (float) this; else if (type == GType.Double.Val)