Commit fed25735 authored by Jonathan Beck's avatar Jonathan Beck

Unlink previous node in SetParent().

parent 1bc33397
......@@ -38,6 +38,8 @@ class Structure : public Node
std::string ToXml();
std::vector<char> ToBin();
virtual void Remove(Node* node) = 0;
protected:
Structure(Node* parent = NULL);
......
......@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <plist/Node.h>
#include <plist/Structure.h>
namespace PList
{
......@@ -96,6 +97,16 @@ Node* Node::GetParent()
void Node::SetParent(Node* parent)
{
//Unlink node first
if ( NULL != _parent )
{
plist_type type = plist_get_node_type(_parent);
if (PLIST_ARRAY ==type || PLIST_DICT == type )
{
Structure* s = static_cast<Structure*>(_parent);
s->Remove(this);
}
}
_parent = parent;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment