[gxml] GomObject: Avoids to set non-instantiatable attributes



commit 32b3f4edafcf36cf122a7c9d0121c4b1f7de1e97
Author: Daniel Espinosa <esodan gmail com>
Date:   Thu Oct 26 18:02:23 2017 -0500

    GomObject: Avoids to set non-instantiatable attributes

 gxml/GomObject.vala      |    3 ++-
 test/GomElementTest.vala |    5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/gxml/GomObject.vala b/gxml/GomObject.vala
index df29f27..e718aff 100644
--- a/gxml/GomObject.vala
+++ b/gxml/GomObject.vala
@@ -220,7 +220,8 @@ public interface GXml.GomObject : GLib.Object,
 #endif
     if (prop != null) {
       var v = Value (prop.value_type);
-      if (prop.value_type.is_a (typeof(GomProperty))) {
+      if (prop.value_type.is_a (typeof(GomProperty))
+          && prop.value_type.is_instantiatable ()) {
         get_property (prop.name, ref v);
         GomProperty so = (Object) v as GomProperty;
         if (so == null) {
diff --git a/test/GomElementTest.vala b/test/GomElementTest.vala
index 4a1600f..3c640d2 100644
--- a/test/GomElementTest.vala
+++ b/test/GomElementTest.vala
@@ -25,6 +25,7 @@ using GXml;
 public interface NoInstantiatable : Object, GomObject {
        public abstract string name { get; set; }
 }
+public interface Property : Object, GomProperty {}
 
 class GomElementTest : GXmlTest  {
        public class ParsedDelayed : GomElement {
@@ -43,6 +44,8 @@ class GomElementTest : GXmlTest  {
                public NoInstantiatable inst {
                        get { return inst_i; } set { inst_i = value as Instantiatable; } }
                public Instantiatable inst_i { get; set; }
+               [Description (nick="::pq")]
+               public Property pq { get; set; }
                construct { initialize ("Top"); }
        }
        public static void add_tests () {
@@ -429,7 +432,7 @@ class GomElementTest : GXmlTest  {
                });
                Test.add_func ("/gxml/gom-element/no-instantiatable", () => {
                        try {
-                               string str = """<Top><Instantiatable name="Nop"/></Top>""";
+                               string str = """<Top pq="Qlt"><Instantiatable name="Nop"/></Top>""";
                                var t = new Top ();
                                t.read_from_string (str);
                                assert (t.inst != null);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]