msxml3: Update backing docs refcount in put_documentElement().

This commit is contained in:
Nikolay Sivov 2013-02-26 10:46:33 +04:00 committed by Alexandre Julliard
parent 01dd81a78c
commit e5affa7040
3 changed files with 11 additions and 1 deletions

View File

@ -1538,7 +1538,9 @@ static HRESULT WINAPI domdoc_put_documentElement(
domdoc *This = impl_from_IXMLDOMDocument3( iface );
IXMLDOMNode *elementNode;
xmlNodePtr oldRoot;
xmlDocPtr old_doc;
xmlnode *xmlNode;
int refcount = 0;
HRESULT hr;
TRACE("(%p)->(%p)\n", This, DOMElement);
@ -1554,7 +1556,14 @@ static HRESULT WINAPI domdoc_put_documentElement(
if(xmldoc_remove_orphan(xmlNode->node->doc, xmlNode->node) != S_OK)
WARN("%p is not an orphan of %p\n", xmlNode->node->doc, xmlNode->node);
old_doc = xmlNode->node->doc;
if (old_doc != get_doc(This))
refcount = xmlnode_get_inst_cnt(xmlNode);
/* old root is still orphaned by its document, update refcount from new root */
if (refcount) xmldoc_add_refs(get_doc(This), refcount);
oldRoot = xmlDocSetRootElement( get_doc(This), xmlNode->node);
if (refcount) xmldoc_release_refs(old_doc, refcount);
IXMLDOMNode_Release( elementNode );
if(oldRoot)

View File

@ -294,6 +294,7 @@ extern LONG xmldoc_add_ref( xmlDocPtr doc ) DECLSPEC_HIDDEN;
extern LONG xmldoc_release( xmlDocPtr doc ) DECLSPEC_HIDDEN;
extern LONG xmldoc_add_refs( xmlDocPtr doc, LONG refs ) DECLSPEC_HIDDEN;
extern LONG xmldoc_release_refs ( xmlDocPtr doc, LONG refs ) DECLSPEC_HIDDEN;
extern int xmlnode_get_inst_cnt( xmlnode *node ) DECLSPEC_HIDDEN;
extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
extern HRESULT xmldoc_remove_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN;
extern void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node) DECLSPEC_HIDDEN;

View File

@ -402,7 +402,7 @@ static int node_get_inst_cnt(xmlNodePtr node)
return ret;
}
static int xmlnode_get_inst_cnt(xmlnode *node)
int xmlnode_get_inst_cnt(xmlnode *node)
{
return node_get_inst_cnt(node->node);
}