[gxml] * Fix bug where deserialising objects without an oid all became the first such object, and where ill



commit 35d03b81b4b9266b7335653ed19161b0bdf4d882
Author: Richard Schwarting <aquarichy gmail com>
Date:   Wed Aug 22 12:12:09 2012 -0400

    * Fix bug where deserialising objects without an oid all became the first such object, and where illegal objects get stored in the cache before being detected as such

 gxml/Serialization.vala |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/gxml/Serialization.vala b/gxml/Serialization.vala
index fdc70d4..f8bf6ac 100644
--- a/gxml/Serialization.vala
+++ b/gxml/Serialization.vala
@@ -333,7 +333,7 @@ namespace GXml {
 			if (Serialization.cache == null) {
 				Serialization.cache = new HashTable<string,Object> (str_hash, str_equal);
 			}
-			if (Serialization.cache.contains (oid)) {
+			if (oid != "" && Serialization.cache.contains (oid)) {
 				return Serialization.cache.get (oid);
 			}
 
@@ -349,8 +349,6 @@ namespace GXml {
 			obj = Object.newv (type, new Parameter[] {}); // TODO: causes problems with Enums when 0 isn't a valid enum value (e.g. starts from 2 or something)
 			obj_class = obj.get_class ();
 
-			cache.set (oid, obj);
-
 			if (type.is_a (typeof (Serializable))) {
 				serializable = (Serializable)obj;
 			}
@@ -406,6 +404,9 @@ namespace GXml {
 				}
 			}
 
+			// Set it as the last possible action, so that invalid objects won't end up getting stored
+			Serialization.cache.set (oid, obj);
+
 			return obj;
 		}
 



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