Jacek Caban : mshtml: Added ref counting to node object.
Alexandre Julliard
julliard at winehq.org
Mon Oct 15 11:27:59 CDT 2007
Module: wine
Branch: master
Commit: d6ccaa43a63e700637a88913a8aca10381906414
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d6ccaa43a63e700637a88913a8aca10381906414
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sun Oct 14 12:07:27 2007 +0200
mshtml: Added ref counting to node object.
---
dlls/mshtml/htmlnode.c | 20 ++++++++++++++------
dlls/mshtml/mshtml_private.h | 2 ++
2 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c
index 82e38c4..8eb907a 100644
--- a/dlls/mshtml/htmlnode.c
+++ b/dlls/mshtml/htmlnode.c
@@ -50,19 +50,26 @@ static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface,
static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
{
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
+ LONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p)\n", This);
+ TRACE("(%p) ref=%d\n", This, ref);
- return IHTMLDocument2_AddRef(HTMLDOC(This->doc));
+ return ref;
}
static ULONG WINAPI HTMLDOMNode_Release(IHTMLDOMNode *iface)
{
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
+ LONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)\n", This);
+ TRACE("(%p) ref=%d\n", This, ref);
- return IHTMLDocument2_Release(HTMLDOC(This->doc));
+ if(!ref) {
+ This->vtbl->destructor(This);
+ mshtml_free(This);
+ }
+
+ return ref;
}
static HRESULT WINAPI HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode *iface, UINT *pctinfo)
@@ -352,6 +359,7 @@ static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
}
ret->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
+ ret->ref = 1;
ret->doc = doc;
nsIDOMNode_AddRef(nsnode);
@@ -396,7 +404,7 @@ void release_nodes(HTMLDocument *This)
for(iter = This->nodes; iter; iter = next) {
next = iter->next;
- iter->vtbl->destructor(iter);
- mshtml_free(iter);
+ iter->doc = NULL;
+ IHTMLDOMNode_Release(HTMLDOMNODE(iter));
}
}
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 4c63f60..a493109 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -270,6 +270,8 @@ struct HTMLDOMNode {
const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
const NodeImplVtbl *vtbl;
+ LONG ref;
+
nsIDOMNode *nsnode;
HTMLDocument *doc;
More information about the wine-cvs
mailing list