From 92586f4e0be870a22b95824c2d2a5cd5cdbebee6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Thu, 7 Oct 2010 11:39:11 +0100 Subject: [PATCH] #i112783# ownership cycles in unoxml --- unoxml/source/dom/document.cxx | 38 ---------------------------------- unoxml/source/dom/document.hxx | 5 ----- unoxml/source/dom/node.cxx | 16 ++++---------- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx index 656aa1cbef6c..fcd43832adf0 100644 --- a/unoxml/source/dom/document.cxx +++ b/unoxml/source/dom/document.cxx @@ -53,50 +53,12 @@ namespace DOM { - void CDocument::addnode(xmlNodePtr aNode) - { - if (aNode != (xmlNodePtr)m_aDocPtr) - { - Reference< XNode >* nref = new Reference< XNode >(CNode::get(aNode)); - m_aNodeRefList.push_back(nref); - } - } - CDocument::~CDocument() { - Reference< XNode >* pRef; - nodereflist_t::const_iterator r = m_aNodeRefList.begin(); - while (r!=m_aNodeRefList.end()) - { - pRef = *r; - delete pRef; - r++; - } - - // get rid of leftover instances, if anybody still holds a - // reference to one of these, it will be invalid! - /* - CNode* aNode = 0; - nodelist_t::const_iterator i = m_aNodeList.begin(); - while (i!=m_aNodeList.end()) - { - aNode = CNode::get(*i, sal_False); - if (aNode != 0) - { - // CNode::remove(*i); - // delete will remove - delete aNode; - } - i++; - } - */ - xmlFreeDoc(m_aDocPtr); - } CDocument::CDocument(xmlDocPtr aDocPtr): - m_aNodeRefList(), m_aDocPtr(aDocPtr), m_streamListeners() { diff --git a/unoxml/source/dom/document.hxx b/unoxml/source/dom/document.hxx index b653619031a1..3fe593ff2b24 100644 --- a/unoxml/source/dom/document.hxx +++ b/unoxml/source/dom/document.hxx @@ -72,12 +72,9 @@ namespace DOM XActiveDataControl, XActiveDataSource, XSAXSerializable, XFastSAXSerializable> { friend class CNode; - typedef std::list< Reference< XNode >* > nodereflist_t; typedef set< Reference< XStreamListener > > listenerlist_t; private: - nodereflist_t m_aNodeRefList; - xmlDocPtr m_aDocPtr; // datacontrol/source state @@ -87,8 +84,6 @@ namespace DOM protected: CDocument(xmlDocPtr aDocPtr); - void addnode(xmlNodePtr aNode); - public: virtual ~CDocument(); diff --git a/unoxml/source/dom/node.cxx b/unoxml/source/dom/node.cxx index fb4a6bf508b3..d4b317b425b3 100644 --- a/unoxml/source/dom/node.cxx +++ b/unoxml/source/dom/node.cxx @@ -228,7 +228,7 @@ namespace DOM // m_aNodeType = NodeType::NOTATION_NODE; pNode = static_cast< CNode* >(new CAttr((xmlAttrPtr)aNode)); break; - // unsopported node types + // unsupported node types case XML_HTML_DOCUMENT_NODE: case XML_ELEMENT_DECL: case XML_ATTRIBUTE_DECL: @@ -238,18 +238,10 @@ namespace DOM pNode = 0; break; } - } - if ( pNode != 0 ) - { - if(CNode::theNodeMap.insert(nodemap_t::value_type(aNode, pNode)).second) + + if ( pNode != 0 ) { - // insertion done, register node with document - xmlDocPtr doc = aNode->doc; - if( doc != NULL) - { - CDocument* pDoc = static_cast< CDocument* >(CNode::get((xmlNodePtr)doc)); - pDoc->addnode(aNode); - } else + if(!CNode::theNodeMap.insert(nodemap_t::value_type(aNode, pNode)).second) { // if insertion failed, delete the new instance and return null delete pNode;