diff options
| -rw-r--r-- | include/plist/Structure.h | 2 | ||||
| -rw-r--r-- | src/Node.cpp | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/plist/Structure.h b/include/plist/Structure.h index 6f100cc..239a8b8 100644 --- a/include/plist/Structure.h +++ b/include/plist/Structure.h | |||
| @@ -38,6 +38,8 @@ class Structure : public Node | |||
| 38 | 38 | ||
| 39 | std::string ToXml(); | 39 | std::string ToXml(); |
| 40 | std::vector<char> ToBin(); | 40 | std::vector<char> ToBin(); |
| 41 | |||
| 42 | virtual void Remove(Node* node) = 0; | ||
| 41 | 43 | ||
| 42 | protected: | 44 | protected: |
| 43 | Structure(Node* parent = NULL); | 45 | Structure(Node* parent = NULL); |
diff --git a/src/Node.cpp b/src/Node.cpp index e513862..c6a5b51 100644 --- a/src/Node.cpp +++ b/src/Node.cpp | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
| 22 | #include <plist/Node.h> | 22 | #include <plist/Node.h> |
| 23 | #include <plist/Structure.h> | ||
| 23 | 24 | ||
| 24 | namespace PList | 25 | namespace PList |
| 25 | { | 26 | { |
| @@ -96,6 +97,16 @@ Node* Node::GetParent() | |||
| 96 | 97 | ||
| 97 | void Node::SetParent(Node* parent) | 98 | void Node::SetParent(Node* parent) |
| 98 | { | 99 | { |
| 100 | //Unlink node first | ||
| 101 | if ( NULL != _parent ) | ||
| 102 | { | ||
| 103 | plist_type type = plist_get_node_type(_parent); | ||
| 104 | if (PLIST_ARRAY ==type || PLIST_DICT == type ) | ||
| 105 | { | ||
| 106 | Structure* s = static_cast<Structure*>(_parent); | ||
| 107 | s->Remove(this); | ||
| 108 | } | ||
| 109 | } | ||
| 99 | _parent = parent; | 110 | _parent = parent; |
| 100 | } | 111 | } |
| 101 | 112 | ||
