Commit 97e5728d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

hhctrl.ocx: Fixed ref count handling in IOleClientSiteImpl.

parent 9f5748e6
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "hhctrl.h" #include "hhctrl.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(htmlhelp);
#define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field)) #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field))
typedef struct IOleClientSiteImpl typedef struct IOleClientSiteImpl
...@@ -37,45 +41,62 @@ typedef struct IOleClientSiteImpl ...@@ -37,45 +41,62 @@ typedef struct IOleClientSiteImpl
HWND hwndWindow; HWND hwndWindow;
} IOleClientSiteImpl; } IOleClientSiteImpl;
#define CLIENTSITE(x) ((IOleClientSite*) &(x)->lpVtbl)
#define DOCHOSTUI(x) ((IDocHostUIHandler*) &(x)->lpvtblDocHostUIHandler)
#define INPLACESITE(x) ((IOleInPlaceSite*) &(x)->lpvtblOleInPlaceSite)
#define INPLACEFRAME(x) ((IOleInPlaceFrame*) &(x)->lpvtblOleInPlaceFrame)
static HRESULT STDMETHODCALLTYPE Site_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppvObj) static HRESULT STDMETHODCALLTYPE Site_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppvObj)
{ {
ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface); ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
*ppvObj = NULL; *ppvObj = NULL;
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IOleClientSite)) if (IsEqualIID(riid, &IID_IUnknown)) {
{ TRACE("(%p)->(IID_IUnknown %p)\n", This, ppvObj);
*ppvObj = This; *ppvObj = CLIENTSITE(This);
} }else if(IsEqualIID(riid, &IID_IOleClientSite)) {
else if (IsEqualIID(riid, &IID_IOleInPlaceSite)) TRACE("(%p)->(IID_IOleClientSite %p)\n", This, ppvObj);
{ *ppvObj = CLIENTSITE(This);
}else if (IsEqualIID(riid, &IID_IOleInPlaceSite)) {
TRACE("(%p)->(IID_IOleInPlaceSite %p)\n", This, ppvObj);
*ppvObj = &(This->lpvtblOleInPlaceSite); *ppvObj = &(This->lpvtblOleInPlaceSite);
} }else if (IsEqualIID(riid, &IID_IOleInPlaceFrame)) {
else if (IsEqualIID(riid, &IID_IDocHostUIHandler)) TRACE("(%p)->(IID_IOleInPlaceFrame %p)\n", This, ppvObj);
{ *ppvObj = &(This->lpvtblOleInPlaceSite);
}else if (IsEqualIID(riid, &IID_IDocHostUIHandler)) {
TRACE("(%p)->(IID_IDocHostUIHandler %p)\n", This, ppvObj);
*ppvObj = &(This->lpvtblDocHostUIHandler); *ppvObj = &(This->lpvtblDocHostUIHandler);
} }else {
else TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObj);
return E_NOINTERFACE; return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppvObj);
return S_OK; return S_OK;
} }
static ULONG STDMETHODCALLTYPE Site_AddRef(IOleClientSite *iface) static ULONG STDMETHODCALLTYPE Site_AddRef(IOleClientSite *iface)
{ {
ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface); ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
return InterlockedIncrement(&This->ref); LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
} }
static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface) static ULONG STDMETHODCALLTYPE Site_Release(IOleClientSite *iface)
{ {
ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface); ICOM_THIS_MULTI(IOleClientSiteImpl, lpVtbl, iface);
LONG refCount = InterlockedDecrement(&This->ref); LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if (refCount) if(!ref)
return refCount; heap_free(This);
heap_free(This); return ref;
return 0;
} }
static HRESULT STDMETHODCALLTYPE Site_SaveObject(IOleClientSite *iface) static HRESULT STDMETHODCALLTYPE Site_SaveObject(IOleClientSite *iface)
...@@ -126,17 +147,22 @@ static const IOleClientSiteVtbl MyIOleClientSiteTable = ...@@ -126,17 +147,22 @@ static const IOleClientSiteVtbl MyIOleClientSiteTable =
static HRESULT STDMETHODCALLTYPE UI_QueryInterface(IDocHostUIHandler *iface, REFIID riid, LPVOID *ppvObj) static HRESULT STDMETHODCALLTYPE UI_QueryInterface(IDocHostUIHandler *iface, REFIID riid, LPVOID *ppvObj)
{ {
ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface); ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
return Site_QueryInterface((IOleClientSite *)This, riid, ppvObj);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
} }
static ULONG STDMETHODCALLTYPE UI_AddRef(IDocHostUIHandler *iface) static ULONG STDMETHODCALLTYPE UI_AddRef(IDocHostUIHandler *iface)
{ {
return 1; ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
return IOleClientSite_AddRef(CLIENTSITE(This));
} }
static ULONG STDMETHODCALLTYPE UI_Release(IDocHostUIHandler * iface) static ULONG STDMETHODCALLTYPE UI_Release(IDocHostUIHandler * iface)
{ {
return 2; ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblDocHostUIHandler, iface);
return IOleClientSite_Release(CLIENTSITE(This));
} }
static HRESULT STDMETHODCALLTYPE UI_ShowContextMenu(IDocHostUIHandler *iface, DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved) static HRESULT STDMETHODCALLTYPE UI_ShowContextMenu(IDocHostUIHandler *iface, DWORD dwID, POINT *ppt, IUnknown *pcmdtReserved, IDispatch *pdispReserved)
...@@ -246,17 +272,22 @@ static const IDocHostUIHandlerVtbl MyIDocHostUIHandlerTable = ...@@ -246,17 +272,22 @@ static const IDocHostUIHandlerVtbl MyIDocHostUIHandlerTable =
static HRESULT STDMETHODCALLTYPE InPlace_QueryInterface(IOleInPlaceSite *iface, REFIID riid, LPVOID *ppvObj) static HRESULT STDMETHODCALLTYPE InPlace_QueryInterface(IOleInPlaceSite *iface, REFIID riid, LPVOID *ppvObj)
{ {
ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface); ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
return Site_QueryInterface((IOleClientSite *)This, riid, ppvObj);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
} }
static ULONG STDMETHODCALLTYPE InPlace_AddRef(IOleInPlaceSite *iface) static ULONG STDMETHODCALLTYPE InPlace_AddRef(IOleInPlaceSite *iface)
{ {
return 1; ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
return IOleClientSite_AddRef(CLIENTSITE(This));
} }
static ULONG STDMETHODCALLTYPE InPlace_Release(IOleInPlaceSite *iface) static ULONG STDMETHODCALLTYPE InPlace_Release(IOleInPlaceSite *iface)
{ {
return 2; ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
return IOleClientSite_Release(CLIENTSITE(This));
} }
static HRESULT STDMETHODCALLTYPE InPlace_GetWindow(IOleInPlaceSite *iface, HWND *lphwnd) static HRESULT STDMETHODCALLTYPE InPlace_GetWindow(IOleInPlaceSite *iface, HWND *lphwnd)
...@@ -290,7 +321,10 @@ static HRESULT STDMETHODCALLTYPE InPlace_OnUIActivate(IOleInPlaceSite *iface) ...@@ -290,7 +321,10 @@ static HRESULT STDMETHODCALLTYPE InPlace_OnUIActivate(IOleInPlaceSite *iface)
static HRESULT STDMETHODCALLTYPE InPlace_GetWindowContext(IOleInPlaceSite *iface, LPOLEINPLACEFRAME *lplpFrame, LPOLEINPLACEUIWINDOW *lplpDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo) static HRESULT STDMETHODCALLTYPE InPlace_GetWindowContext(IOleInPlaceSite *iface, LPOLEINPLACEFRAME *lplpFrame, LPOLEINPLACEUIWINDOW *lplpDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
{ {
ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface); ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceSite, iface);
*lplpFrame = (LPOLEINPLACEFRAME)&This->lpvtblOleInPlaceFrame;
*lplpFrame = INPLACEFRAME(This);
IOleInPlaceFrame_AddRef(INPLACEFRAME(This));
*lplpDoc = NULL; *lplpDoc = NULL;
lpFrameInfo->fMDIApp = FALSE; lpFrameInfo->fMDIApp = FALSE;
...@@ -358,17 +392,23 @@ static const IOleInPlaceSiteVtbl MyIOleInPlaceSiteTable = ...@@ -358,17 +392,23 @@ static const IOleInPlaceSiteVtbl MyIOleInPlaceSiteTable =
static HRESULT STDMETHODCALLTYPE Frame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, LPVOID *ppvObj) static HRESULT STDMETHODCALLTYPE Frame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, LPVOID *ppvObj)
{ {
return E_NOTIMPL; ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
return IOleClientSite_QueryInterface(CLIENTSITE(This), riid, ppvObj);
} }
static ULONG STDMETHODCALLTYPE Frame_AddRef(IOleInPlaceFrame *iface) static ULONG STDMETHODCALLTYPE Frame_AddRef(IOleInPlaceFrame *iface)
{ {
return 1; ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
return IOleClientSite_AddRef(CLIENTSITE(This));
} }
static ULONG STDMETHODCALLTYPE Frame_Release(IOleInPlaceFrame *iface) static ULONG STDMETHODCALLTYPE Frame_Release(IOleInPlaceFrame *iface)
{ {
return 2; ICOM_THIS_MULTI(IOleClientSiteImpl, lpvtblOleInPlaceFrame, iface);
return IOleClientSite_Release(CLIENTSITE(This));
} }
static HRESULT STDMETHODCALLTYPE Frame_GetWindow(IOleInPlaceFrame *iface, HWND *lphwnd) static HRESULT STDMETHODCALLTYPE Frame_GetWindow(IOleInPlaceFrame *iface, HWND *lphwnd)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment