Nikolay Sivov : msxml3: Update backing docs refcount in put_documentElement ().
Alexandre Julliard
julliard at winehq.org
Wed Feb 27 14:41:58 CST 2013
Module: wine
Branch: master
Commit: e5affa70400b67eb2abb66666e5f5eccba17ef5f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e5affa70400b67eb2abb66666e5f5eccba17ef5f
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue Feb 26 10:46:33 2013 +0400
msxml3: Update backing docs refcount in put_documentElement().
---
dlls/msxml3/domdoc.c | 9 +++++++++
dlls/msxml3/msxml_private.h | 1 +
dlls/msxml3/node.c | 2 +-
3 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c
index fb96ba0..32e9591 100644
--- a/dlls/msxml3/domdoc.c
+++ b/dlls/msxml3/domdoc.c
@@ -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)
diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h
index 3109a42..6c24119 100644
--- a/dlls/msxml3/msxml_private.h
+++ b/dlls/msxml3/msxml_private.h
@@ -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;
diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c
index 20f9ba9..4508609 100644
--- a/dlls/msxml3/node.c
+++ b/dlls/msxml3/node.c
@@ -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);
}
More information about the wine-cvs
mailing list