From a8091a9031f26dcdab1e14a55fd46d0603c225de Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Wed, 1 Jun 2011 11:19:42 +0300 Subject: When reparenting, remove child from old parent --- sxml.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sxml.cpp') diff --git a/sxml.cpp b/sxml.cpp index 0e23833..e09de0b 100644 --- a/sxml.cpp +++ b/sxml.cpp @@ -59,6 +59,20 @@ node::~node() node *node::add_child(node *child) { + if (child->m_parent != NULL) + { + node_list::iterator i = child->m_parent->m_children.begin(); + for (; i != child->m_parent->m_children.end(); ++i) + { + if (*i == child) + { + child->m_parent->m_children.erase(i); + child->m_parent->set_modified(true); + break; + } + } + } + child->m_parent = this; m_children.push_back(child); set_modified(true); -- cgit v1.2.3