From 7913019fd0baadd921f8a88c3114a7ac7e3c7234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Fri, 4 Aug 2023 17:30:14 +0300 Subject: [PATCH] mshtml: Use unlink and destructor in the vtbl for XMLHttpRequest. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu --- dlls/mshtml/xmlhttprequest.c | 43 +++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 73eea9d7f6d..75f52fb6c8e 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -550,17 +550,8 @@ static ULONG WINAPI HTMLXMLHttpRequest_Release(IHTMLXMLHttpRequest *iface) TRACE("(%p) ref=%ld\n", This, ref); - if(!ref) { - remove_target_tasks(This->task_magic); - detach_xhr_event_listener(This->event_listener); - if(This->pending_progress_event) - IDOMEvent_Release(&This->pending_progress_event->IDOMEvent_iface); - IHTMLWindow2_Release(&This->window->base.IHTMLWindow2_iface); - release_event_target(&This->event_target); + if(!ref) release_dispex(&This->event_target.dispex); - nsIXMLHttpRequest_Release(This->nsxhr); - free(This); - } return ref; } @@ -1530,6 +1521,35 @@ static inline HTMLXMLHttpRequest *impl_from_DispatchEx(DispatchEx *iface) return CONTAINING_RECORD(iface, HTMLXMLHttpRequest, event_target.dispex); } +static void HTMLXMLHttpRequest_unlink(DispatchEx *dispex) +{ + HTMLXMLHttpRequest *This = impl_from_DispatchEx(dispex); + remove_target_tasks(This->task_magic); + if(This->event_listener) { + XMLHttpReqEventListener *event_listener = This->event_listener; + This->event_listener = NULL; + detach_xhr_event_listener(event_listener); + } + if(This->window) { + HTMLInnerWindow *window = This->window; + This->window = NULL; + IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); + } + if(This->pending_progress_event) { + DOMEvent *pending_progress_event = This->pending_progress_event; + This->pending_progress_event = NULL; + IDOMEvent_Release(&pending_progress_event->IDOMEvent_iface); + } + unlink_ref(&This->nsxhr); + release_event_target(&This->event_target); +} + +static void HTMLXMLHttpRequest_destructor(DispatchEx *dispex) +{ + HTMLXMLHttpRequest *This = impl_from_DispatchEx(dispex); + free(This); +} + static nsISupports *HTMLXMLHttpRequest_get_gecko_target(DispatchEx *dispex) { HTMLXMLHttpRequest *This = impl_from_DispatchEx(dispex); @@ -1574,7 +1594,8 @@ static void HTMLXMLHttpRequest_init_dispex_info(dispex_data_t *info, compat_mode static event_target_vtbl_t HTMLXMLHttpRequest_event_target_vtbl = { { - NULL, + HTMLXMLHttpRequest_destructor, + HTMLXMLHttpRequest_unlink }, HTMLXMLHttpRequest_get_gecko_target, HTMLXMLHttpRequest_bind_event