mshtml: Remove the inner window ref from the doc only when it is actually unlinked.

This commit is contained in:
Gabriel Ivăncescu 2023-11-30 17:51:54 +02:00 committed by Alexandre Julliard
parent 1593f2f508
commit 068f244063
2 changed files with 14 additions and 7 deletions

View file

@ -5707,12 +5707,6 @@ void detach_document_node(HTMLDocumentNode *doc)
{
unsigned i;
if(doc->window) {
HTMLInnerWindow *window = doc->window;
doc->window = NULL;
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
}
while(!list_empty(&doc->plugin_hosts))
detach_plugin_host(LIST_ENTRY(list_head(&doc->plugin_hosts), PluginHost, entry));
@ -5884,14 +5878,20 @@ static void HTMLDocumentNode_traverse(DispatchEx *dispex, nsCycleCollectionTrave
static void HTMLDocumentNode_unlink(DispatchEx *dispex)
{
HTMLDocumentNode *This = impl_from_DispatchEx(dispex);
HTMLInnerWindow *window = This->window;
HTMLDOMNode_unlink(dispex);
if(window) {
This->window = NULL;
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
}
if(This->dom_document) {
release_document_mutation(This);
detach_document_node(This);
This->dom_document = NULL;
This->html_document = NULL;
}else if(This->window) {
}else if(window) {
detach_document_node(This);
}
}

View file

@ -3589,7 +3589,14 @@ static void test_doc_obj(IHTMLDocument2 *doc)
ok(hres == S_OK, "get_document failed: %08lx\n", hres);
ok(doc_node != doc_node2, "doc_node == doc_node2\n");
IHTMLDocument2_Release(doc_node2);
hres = IHTMLDocument2_get_parentWindow(doc_node, &window2);
todo_wine
ok(hres == S_OK, "get_parentWindow failed: %08lx\n", hres);
todo_wine
ok(window == window2, "window != window2\n");
IHTMLDocument2_Release(doc_node);
if(hres == S_OK) IHTMLWindow2_Release(window2);
hres = IHTMLWindow2_get_location(window, &location2);
ok(hres == S_OK, "get_location failed: %08lx\n", hres);