Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Shared/XML/CXMLNodeImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,20 @@ CXMLNodeImpl::~CXMLNodeImpl()
if (m_bUsingIDs)
CXMLArray::PushUniqueID(this);

// Delete our children
// Delete wrapper children first so each child unlinks its own tinyxml2 node
// before this node is removed from the document.
DeleteAllSubNodes();

// Keep the underlying document in sync when nodes are destroyed via
// xmlDestroyNode. DeleteWrapper nulls m_pNode before delete to avoid
// unlinking during full file teardown.
if (m_pNode)
{
if (XMLNode* pXmlParent = m_pNode->Parent())
pXmlParent->DeleteChild(m_pNode);
m_pNode = nullptr;
}

// We need a parent to delete the node
if (m_pParent)
{
Expand Down