From e1b30131820704e524587b6601202f6c54aba88b Mon Sep 17 00:00:00 2001 From: Stephan Friedrichs Date: Thu, 7 Mar 2019 21:30:23 +0100 Subject: [PATCH] Issue 742: allow intermittent calls of XMLPrinter::ClearBuffer XMLPrinter::ClearBuffer shouldn't set _firstElement to true, unless called after the document is completely generated. Otherwise, the layout of the XML file is messed up when the buffer is flushed intermittently. This commit enables this using a default-initialized parameter, chosen such that the existing behavior remains uneffected. --- tinyxml2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tinyxml2.h b/tinyxml2.h index ee83d2c..7ba7ca0 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -2253,10 +2253,10 @@ public: If in print to memory mode, reset the buffer to the beginning. */ - void ClearBuffer() { + void ClearBuffer( bool resetToFirstElement = true ) { _buffer.Clear(); _buffer.Push(0); - _firstElement = true; + _firstElement = resetToFirstElement; } protected: