Explorar o código

Issue299 - Allow Accept() to work with element trees that are not
linked in to the owning document.

Ant Mitchell %!s(int64=11) %!d(string=hai) anos
pai
achega
7e744771ad
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      tinyxml2.cpp

+ 6 - 2
tinyxml2.cpp

@@ -2297,8 +2297,12 @@ bool XMLPrinter::VisitEnter( const XMLDocument& doc )
 
 
 bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
 bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute )
 {
 {
-	const XMLElement*	parentElem = element.Parent()->ToElement();
-	bool		compactMode = parentElem ? CompactMode(*parentElem) : _compactMode;
+    const XMLElement*	parentElem = NULL;
+    if (  element.Parent() )
+    {
+	parentElem = element.Parent()->ToElement();
+    }
+    bool		compactMode = parentElem ? CompactMode(*parentElem) : _compactMode;
     OpenElement( element.Name(), compactMode );
     OpenElement( element.Name(), compactMode );
     while ( attribute ) {
     while ( attribute ) {
         PushAttribute( attribute->Name(), attribute->Value() );
         PushAttribute( attribute->Name(), attribute->Value() );