* Check for missing attribute
authorspixx <spixx>
Sat, 11 Nov 2006 13:15:43 +0000 (13:15 +0000)
committerspixx <spixx>
Sat, 11 Nov 2006 13:15:43 +0000 (13:15 +0000)
src/xmlstructure.cpp

index f2832c3a86f02ca19150cb01be944ab4a1618a81..278f270cf2513e0bbaeb6c3cd33a5dfd0125fbb3 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (C) 2006 Erik Dahlberg
 // 
 // Copyright (C) 2006 Erik Dahlberg
 // 
-// This file is part of LSystem3d.
+// This file is part of LSystem3D.
 // 
 // LSystem3D is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
 // 
 // LSystem3D is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@
 
 #include <string>
 
 
 #include <string>
 
+#include <libxml++/attribute.h>
 #include <libxml++/document.h>
 #include <libxml++/nodes/element.h>
 #include <libxml++/nodes/node.h>
 #include <libxml++/document.h>
 #include <libxml++/nodes/element.h>
 #include <libxml++/nodes/node.h>
@@ -225,7 +226,13 @@ string XMLStructure::getAttribute(string name)
     xmlpp::Element *child = dynamic_cast<xmlpp::Element*>(*_activeChildInList);
     
     // its attribute value
     xmlpp::Element *child = dynamic_cast<xmlpp::Element*>(*_activeChildInList);
     
     // its attribute value
-    string attributeValue = child->get_attribute(name)->get_value();
+    string attributeValue;
+    xmlpp::Attribute *attribute = child->get_attribute(name);
+    
+    if (attribute)
+    {
+        attributeValue = attribute->get_value();
+    }
     
     return attributeValue;
 }
     
     return attributeValue;
 }