changeset 21:51f05fd6a626

Merged changes from dsource repository.
author Jacob Carlborg <doob@me.com>
date Mon, 04 Oct 2010 20:18:02 +0200
parents 9a575087b961
children 963b756ed579
files orange/serialization/archives/XMLArchive.d
diffstat 1 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/orange/serialization/archives/XMLArchive.d	Mon Oct 04 18:27:21 2010 +0200
+++ b/orange/serialization/archives/XMLArchive.d	Mon Oct 04 20:18:02 2010 +0200
@@ -416,8 +416,16 @@
 		lastElement = tmp;
 		
 		auto runtimeType = getValueOfAttribute(Attributes.runtimeTypeAttribute);
+		
+		if (!runtimeType)
+			return T.init;			
+		
 		auto name = fromDataType!(string)(runtimeType);
-		id = getValueOfAttribute(Attributes.idAttribute);				
+		id = getValueOfAttribute(Attributes.idAttribute);
+		
+		if (!id)
+			return T.init;
+		
 		T result = cast(T) newInstance(name);
 		
 		addUnarchivedReference(result, id);
@@ -473,10 +481,17 @@
 			return T.init;
 		
 		lastElement = element;
-		auto length = getValueOfAttribute(Attributes.lengthAttribute);		
+		auto length = getValueOfAttribute(Attributes.lengthAttribute);
+		
+		if (!length)
+			return T.init;
+		
 		value.length = fromDataType!(size_t)(length);
 		slice.id = getValueOfAttribute(Attributes.idAttribute);	
 		
+		if (!slice.id)
+			return T.init;
+		
 		addUnarchivedSlice(value, slice.id);
 		
 		return value;
@@ -509,6 +524,9 @@
 
 		lastElement = element; 
 		id = getValueOfAttribute(Attributes.idAttribute);
+		
+		if (!id)
+			return T.init;
 				
 		T result = new BaseTypeOfPointer!(T);
 		
@@ -617,7 +635,7 @@
 			}
 
 			return doc.Node.invalid;
-		}		
+		}
 	}
 	
 	private DataType getValueOfAttribute (DataType attribute, doc.Node element = doc.Node.invalid)
@@ -639,7 +657,9 @@
 				else
 					errorCallback(new ArchiveException(`Could not unarchive the value of the attribute "` ~ to!(string)(attribute) ~ `" due to malformed data.`, __FILE__, __LINE__), [attribute]);
 			}
-		}		
+		}
+		
+		return null;
 	}
 	
 	private void addArchivedReference (T) (T value, DataType id)