From bccd244a70532efe9bb7f23fb62f5cff9524d919 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Tue, 12 May 2009 23:53:50 +0000 Subject: [PATCH] 2009-05-12 Mike Kestner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * glib/Value.cs: explicit exception for unknown props. [Fixes #502043] Patch by Sebastian Dröge. svn path=/trunk/gtk-sharp/; revision=134021 --- ChangeLog | 5 +++++ glib/Value.cs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3c8737481..d513af38a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-05-12 Mike Kestner + + * glib/Value.cs: explicit exception for unknown props. + [Fixes #502043] Patch by Sebastian Dröge. + 2009-05-12 Mike Kestner * glib/ValueArray.cs: make ctor(IntPtr) public for binding usage. diff --git a/glib/Value.cs b/glib/Value.cs index 6d143f036..297ebfa5c 100755 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -525,8 +525,13 @@ namespace GLib { void InitForProperty (GType gtype, string name) { IntPtr p_name = Marshaller.StringToPtrGStrdup (name); - ParamSpec spec = new ParamSpec (g_object_class_find_property (gtype.ClassPtr, p_name)); + IntPtr spec_ptr = g_object_class_find_property (gtype.ClassPtr, p_name); Marshaller.Free (p_name); + + if (spec_ptr == IntPtr.Zero) + throw new Exception (String.Format ("No property with name '{0}' in type '{1}'", name, gtype.ToString())); + + ParamSpec spec = new ParamSpec (spec_ptr); g_value_init (ref this, spec.ValueType.Val); }