mirror of https://github.com/AxioDL/tinyxml2.git
Merge branch 'Haloric-Issue299'
This commit is contained in:
commit
ea21390f28
|
@ -2297,8 +2297,11 @@ bool XMLPrinter::VisitEnter( const XMLDocument& doc )
|
|||
|
||||
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 );
|
||||
while ( attribute ) {
|
||||
PushAttribute( attribute->Name(), attribute->Value() );
|
||||
|
|
|
@ -1425,6 +1425,14 @@ int main( int argc, const char ** argv )
|
|||
XMLPrinter printer;
|
||||
doc.Print( &printer );
|
||||
}
|
||||
{
|
||||
// Issue 299. Can print elements that are not linked in.
|
||||
// Will crash if issue not fixed.
|
||||
XMLDocument doc;
|
||||
XMLElement* newElement = doc.NewElement( "printme" );
|
||||
XMLPrinter printer;
|
||||
newElement->Accept( &printer );
|
||||
}
|
||||
|
||||
// ----------- Performance tracking --------------
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue