[gxml] GomDocument: fix find root element with canonical names
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] GomDocument: fix find root element with canonical names
- Date: Thu, 21 Mar 2019 19:44:06 +0000 (UTC)
commit 47c88d348178782ae6e33110705b4285a798b6c5
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Mar 21 13:35:02 2019 -0600
GomDocument: fix find root element with canonical names
gxml/GomDocument.vala | 6 +++++-
test/GomDocumentTest.vala | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gxml/GomDocument.vala b/gxml/GomDocument.vala
index 9a75075..d688290 100644
--- a/gxml/GomDocument.vala
+++ b/gxml/GomDocument.vala
@@ -103,7 +103,11 @@ public class GXml.GomDocument : GomNode,
private GomElement get_root_gom_element () {
Object obj = null;
foreach (ParamSpec spec in this.get_class ().list_properties ()) {
- if ("::" in spec.get_nick () && spec.name.down () == "root") {
+ if ("::" in spec.get_nick ()) {
+ string name = spec.get_nick ().down ().replace ("::", "");
+ if (name != "root") {
+ continue;
+ }
if (spec.value_type.is_a (typeof (GomElement))) {
Value val = Value (Type.OBJECT);
get_property (spec.name, ref val);
diff --git a/test/GomDocumentTest.vala b/test/GomDocumentTest.vala
index 5a86f03..f7edf33 100644
--- a/test/GomDocumentTest.vala
+++ b/test/GomDocumentTest.vala
@@ -25,7 +25,7 @@ using GXml;
class GomDocumentTest : GXmlTest {
class ObjectDocument : GomDocument {
[Description (nick="::ROOT")]
- public ObjectParent root { get; set; }
+ public ObjectParent root_element { get; set; }
public class ObjectParent : GomElement {
construct {
try { initialize ("root"); }
@@ -756,7 +756,7 @@ class GomDocumentTest : GXmlTest {
var d = new ObjectDocument ();
d.read_from_string ("""<root><child id="id1"/><child id="id2"/></root>""");
message (d.write_string ());
- assert (d.root != null);
+ assert (d.root_element != null);
} catch (GLib.Error e) {
GLib.message ("Error: "+e.message);
assert_not_reached ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]