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 };