From 159b6d75d0e293d9b1cb1ef546252946ec4acb38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Thu, 3 Aug 2023 15:56:12 +0300 Subject: [PATCH] mshtml: Use unlink and destructor in the vtbl for HTMLSelectionObject. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu --- dlls/mshtml/selection.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/dlls/mshtml/selection.c b/dlls/mshtml/selection.c index 03a330d3f30..cc9c0acece6 100644 --- a/dlls/mshtml/selection.c +++ b/dlls/mshtml/selection.c @@ -93,14 +93,8 @@ static ULONG WINAPI HTMLSelectionObject_Release(IHTMLSelectionObject *iface) TRACE("(%p) ref=%ld\n", This, ref); - if(!ref) { - if(This->nsselection) - nsISelection_Release(This->nsselection); - if(This->doc) - list_remove(&This->entry); + if(!ref) release_dispex(&This->dispex); - free(This); - } return ref; } @@ -329,6 +323,32 @@ static const IHTMLSelectionObject2Vtbl HTMLSelectionObject2Vtbl = { HTMLSelectionObject2_get_typeDetail }; +static inline HTMLSelectionObject *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLSelectionObject, dispex); +} + +static void HTMLSelectionObject_unlink(DispatchEx *dispex) +{ + HTMLSelectionObject *This = impl_from_DispatchEx(dispex); + unlink_ref(&This->nsselection); + if(This->doc) { + This->doc = NULL; + list_remove(&This->entry); + } +} + +static void HTMLSelectionObject_destructor(DispatchEx *dispex) +{ + HTMLSelectionObject *This = impl_from_DispatchEx(dispex); + free(This); +} + +static const dispex_static_data_vtbl_t HTMLSelectionObject_dispex_vtbl = { + HTMLSelectionObject_destructor, + HTMLSelectionObject_unlink +}; + static const tid_t HTMLSelectionObject_iface_tids[] = { IHTMLSelectionObject_tid, IHTMLSelectionObject2_tid, @@ -336,7 +356,7 @@ static const tid_t HTMLSelectionObject_iface_tids[] = { }; static dispex_static_data_t HTMLSelectionObject_dispex = { L"MSSelection", - NULL, + &HTMLSelectionObject_dispex_vtbl, IHTMLSelectionObject_tid, /* FIXME: We have a test for that, but it doesn't expose IHTMLSelectionObject2 iface. */ HTMLSelectionObject_iface_tids };