# HG changeset patch # User Jacob Carlborg # Date 1312882730 -7200 # Node ID d6fbd0b3586e99200359f14b1238d130b52114e5 # Parent 3cd22957e411dca3887cc018d2966fcdab15a7d2 Issue 8: Wrong results for array of arrays. (Temporary fix). diff -r 3cd22957e411 -r d6fbd0b3586e orange/serialization/Serializer.d --- a/orange/serialization/Serializer.d Tue Aug 09 10:13:29 2011 +0200 +++ b/orange/serialization/Serializer.d Tue Aug 09 11:38:50 2011 +0200 @@ -551,7 +551,7 @@ private T deserializeArray (T) (string key) { auto slice = deserializeSlice(key); - + if (auto tmp = getDeserializedSlice!(T)(slice)) return *tmp; @@ -563,7 +563,7 @@ foreach (i, ref e ; value) e = deserializeInternal!(typeof(e))(toData(i)); }; - + if (slice.id != size_t.max) { archive.unarchiveArray(slice.id, dg); @@ -578,7 +578,7 @@ if (auto a = slice.id in deserializedSlices) return cast(T) *a; - + addDeserializedSlice(value, slice.id); return value; diff -r 3cd22957e411 -r d6fbd0b3586e orange/serialization/archives/XMLArchive.d --- a/orange/serialization/archives/XMLArchive.d Tue Aug 09 10:13:29 2011 +0200 +++ b/orange/serialization/archives/XMLArchive.d Tue Aug 09 11:38:50 2011 +0200 @@ -773,7 +773,7 @@ auto length = fromData!(size_t)(getValueOfAttribute(Attributes.lengthAttribute, element)); auto offset = fromData!(size_t)(getValueOfAttribute(Attributes.offsetAttribute, element)); auto id = toId(element.value); - + return Slice(length, offset, id); } @@ -1051,7 +1051,7 @@ } private doc.Node getElement (Data tag, string key, Data attribute = Attributes.keyAttribute, bool throwOnError = true) - { + { auto set = lastElement.query[tag].attribute((doc.Node node) { if (node.name == attribute && node.value == key) return true; @@ -1059,22 +1059,29 @@ return false; }); - if (set.nodes.length == 1) - return set.nodes[0].parent; + version (Tango) + { + if (set.nodes.length == 1) + return set.nodes[0].parent; + } else + { // Temporary fix, this is probably a problem in the Phobos + // implementation of the XML query function + if (set.nodes.length > 0) + return set.nodes[set.nodes.length - 1].parent; + } + + if (throwOnError && errorCallback) { - if (throwOnError && errorCallback) - { - if (set.nodes.length == 0) - errorCallback(new ArchiveException(`Could not find an element "` ~ to!(string)(tag) ~ `" with the attribute "` ~ to!(string)(Attributes.keyAttribute) ~ `" with the value "` ~ to!(string)(key) ~ `".`, __FILE__, __LINE__), [tag, Attributes.keyAttribute, key]); - - else - errorCallback(new ArchiveException(`Could not unarchive the value with the key "` ~ to!(string)(key) ~ `" due to malformed data.`, __FILE__, __LINE__), [tag, Attributes.keyAttribute, key]); - } + if (set.nodes.length == 0) + errorCallback(new ArchiveException(`Could not find an element "` ~ to!(string)(tag) ~ `" with the attribute "` ~ to!(string)(Attributes.keyAttribute) ~ `" with the value "` ~ to!(string)(key) ~ `".`, __FILE__, __LINE__), [tag, Attributes.keyAttribute, key]); - return doc.Node.invalid; + else + errorCallback(new ArchiveException(`Could not unarchive the value with the key "` ~ to!(string)(key) ~ `" due to malformed data.`, __FILE__, __LINE__), [tag, Attributes.keyAttribute, key]); } + + return doc.Node.invalid; } private Data getValueOfAttribute (Data attribute, doc.Node element = doc.Node.invalid)