aboutsummaryrefslogtreecommitdiff
path: root/sxml.cpp
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2011-06-01 11:19:42 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2011-06-01 11:19:42 +0300
commita8091a9031f26dcdab1e14a55fd46d0603c225de (patch)
treecbab4ac7d1f91a8e586ca9c129eebfb0fab071fc /sxml.cpp
parent8eba476357c8488be510f012594f305848a7eeb6 (diff)
downloadsxml-a8091a9031f26dcdab1e14a55fd46d0603c225de.tar.gz
sxml-a8091a9031f26dcdab1e14a55fd46d0603c225de.zip
When reparenting, remove child from old parent
Diffstat (limited to 'sxml.cpp')
-rw-r--r--sxml.cpp14
1 files changed, 14 insertions, 0 deletions
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);