diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index d16b2ee4275..4e53b2ad91d 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -92,18 +92,38 @@ HRESULT WINAPI IDirect3DVolume9Impl_FreePrivateData(LPDIRECT3DVOLUME9 iface, REF HRESULT WINAPI IDirect3DVolume9Impl_GetContainer(LPDIRECT3DVOLUME9 iface, REFIID riid, void** ppContainer) { IDirect3DVolume9Impl *This = (IDirect3DVolume9Impl *)iface; + IWineD3DBase *wineD3DContainer = NULL; + IUnknown *wineD3DContainerParent = NULL; HRESULT res; - IUnknown *IWineContainer = NULL; - TRACE("(%p) Relay\n", This); - res = IWineD3DVolume_GetContainer(This->wineD3DVolume, riid, (void **)&IWineContainer); + TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer); - /* If this works, the only valid container is a child of resource (volumetexture) */ - if (res == D3D_OK && NULL != ppContainer) { - IWineD3DResource_GetParent((IWineD3DResource *)IWineContainer, (IUnknown **)ppContainer); - IWineD3DResource_Release((IWineD3DResource *)IWineContainer); + if (!ppContainer) { + ERR("Called without a valid ppContainer.\n"); } + /* Get the WineD3D container. */ + res = IWineD3DVolume_GetContainer(This->wineD3DVolume, &IID_IWineD3DBase, (void **)&wineD3DContainer); + if (res != D3D_OK) return res; + + if (!wineD3DContainer) { + ERR("IWineD3DSurface_GetContainer should never return NULL\n"); + } + + /* Get the parent */ + IWineD3DBase_GetParent(wineD3DContainer, &wineD3DContainerParent); + IUnknown_Release(wineD3DContainer); + + if (!wineD3DContainerParent) { + ERR("IWineD3DBase_GetParent should never return NULL\n"); + } + + /* Now, query the interface of the parent for the riid */ + res = IUnknown_QueryInterface(wineD3DContainerParent, riid, ppContainer); + IUnknown_Release(wineD3DContainerParent); + + TRACE("Returning ppContainer %p, *ppContainer %p\n", ppContainer, *ppContainer); + return res; } diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index df9ca858078..3108662dd8d 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -105,10 +105,20 @@ D3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) { ******************************************* */ HRESULT WINAPI IWineD3DVolumeImpl_GetContainer(IWineD3DVolume *iface, REFIID riid, void** ppContainer) { IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; - TRACE("(%p) : returning %p\n", This, This->container); - *ppContainer = This->container; - IUnknown_AddRef(This->container); - return D3D_OK; + + TRACE("(This %p, riid %s, ppContainer %p)\n", This, debugstr_guid(riid), ppContainer); + + if (!ppContainer) { + ERR("Called without a valid ppContainer.\n"); + } + + /* Although surfaces can be standalone, volumes can't */ + if (!This->container) { + ERR("Volume without an container. Should not happen.\n"); + } + + TRACE("Relaying to QueryInterface\n"); + return IUnknown_QueryInterface(This->container, riid, ppContainer); } HRESULT WINAPI IWineD3DVolumeImpl_GetDesc(IWineD3DVolume *iface, WINED3DVOLUME_DESC* pDesc) {