diff options
author | Stef Walter <stef@memberwebs.com> | 2004-09-01 18:07:23 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-09-01 18:07:23 +0000 |
commit | 545348b5c62da57f69b857a2ed323cf8847aedf2 (patch) | |
tree | 1aa69094c6ced0787ab9f7a02930d018d5ef2bef /src | |
parent | e1622ec1957dba431a0df1133833984522ad1118 (diff) |
Fix problems with reference counting
Diffstat (limited to 'src')
-rw-r--r-- | src/domcxx.h | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/domcxx.h b/src/domcxx.h index 9ebc023..abdd622 100644 --- a/src/domcxx.h +++ b/src/domcxx.h @@ -141,9 +141,9 @@ namespace DOM /* We only perform ref counting on nodes outside the tree */ #define INC_NODE_REF(n) \ - if(LOOSE_NODE(n)) incref(n) + if(n) incref(n) #define DEC_NODE_REF(n) \ - if(LOOSE_NODE(n)) decref(n) + if(n) decref(n) /** * Thin wrapper class for a DOM Node @@ -440,13 +440,16 @@ namespace DOM inline void decref(DOM_Node* node) { ASSERT(node); - ASSERT(node->parentNode == NULL); --(node->rtfxRefCount); - if(node->rtfxRefCount <= 0) + if(LOOSE_NODE(node)) { - ASSERT(node->nodeType == DOM_DOCUMENT_NODE || node->ownerDocument); - DOM_Document_destroyNode(node->nodeType == DOM_DOCUMENT_NODE ? - node : node->ownerDocument, node); + ASSERT(node->parentNode == NULL); + if(node->rtfxRefCount <= 0) + { + ASSERT(node->nodeType == DOM_DOCUMENT_NODE || node->ownerDocument); + DOM_Document_destroyNode(node->nodeType == DOM_DOCUMENT_NODE ? + node : node->ownerDocument, node); + } } } }; @@ -1380,7 +1383,7 @@ namespace DOM return *this; } - ~NodeList() + virtual ~NodeList() { DEC_NODELIST_REF(*this); } bool operator==(const NodeList& other) const @@ -1473,13 +1476,15 @@ namespace DOM NamedNodeMap(const NamedNodeMap& list) : NodeList(list) { } + virtual ~NamedNodeMap() {} + NamedNodeMap& operator=(const NamedNodeMap& other) { NodeList::operator=(other); return *this; } NamedNodeMap& operator=(void* null) { NodeList::operator=(null); return *this; } - const NamedNodeMap* operator->() const + const NamedNodeMap* operator->() const { return (const NamedNodeMap*)this; } - NamedNodeMap* operator->() + NamedNodeMap* operator->() { return this; } virtual int getLength() const @@ -1516,7 +1521,7 @@ namespace DOM return node; } - virtual Node removeNamedItem(const dom_str& name) + Node removeNamedItem(const dom_str& name) throw(DOMException) { ASSERT_VALID(); @@ -1536,7 +1541,7 @@ namespace DOM } #endif - virtual Node setNamedItem(const Node& arg) + Node setNamedItem(const Node& arg) throw(DOMException) { ASSERT_VALID(); |