#i112783# ownership cycles in unoxml
This commit is contained in:
parent
9da85b9954
commit
92586f4e0b
3 changed files with 4 additions and 55 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue