Henri Verbeet : wined3d: Fix surface creation error handling.
Alexandre Julliard
julliard at winehq.org
Tue Jan 13 10:56:17 CST 2009
Module: wine
Branch: master
Commit: 99d3c62163f06e9715706d2cbfde9871dab1d779
URL: http://source.winehq.org/git/wine.git/?a=commit;h=99d3c62163f06e9715706d2cbfde9871dab1d779
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Tue Jan 13 10:31:57 2009 +0100
wined3d: Fix surface creation error handling.
---
dlls/wined3d/device.c | 59 ++++++++++++++++++++++++++++--------------------
1 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 8594cb7..2b10c2b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -662,7 +662,31 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
return WINED3DERR_OUTOFVIDEOMEMORY;
}
- object->lpVtbl = &IWineD3DSurface_Vtbl;
+ /* Look at the implementation and set the correct Vtable */
+ switch(Impl)
+ {
+ case SURFACE_OPENGL:
+ /* Check if a 3D adapter is available when creating gl surfaces */
+ if (!This->adapter)
+ {
+ ERR("OpenGL surfaces are not available without opengl\n");
+ HeapFree(GetProcessHeap(), 0, object);
+ return WINED3DERR_NOTAVAILABLE;
+ }
+ object->lpVtbl = &IWineD3DSurface_Vtbl;
+ break;
+
+ case SURFACE_GDI:
+ object->lpVtbl = &IWineGDISurface_Vtbl;
+ break;
+
+ default:
+ /* To be sure to catch this */
+ ERR("Unknown requested surface implementation %d!\n", Impl);
+ HeapFree(GetProcessHeap(), 0, object);
+ return WINED3DERR_INVALIDCALL;
+ }
+
hr = resource_init(&object->resource, WINED3DRTYPE_SURFACE, This, Size, Usage, Format, Pool, parent);
if (FAILED(hr))
{
@@ -745,34 +769,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
This, Width, Height, Format, debug_d3dformat(Format),
(WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->resource.allocatedMemory, object->resource.size);
- /* Look at the implementation and set the correct Vtable */
- switch(Impl) {
- case SURFACE_OPENGL:
- /* Check if a 3D adapter is available when creating gl surfaces */
- if(!This->adapter) {
- ERR("OpenGL surfaces are not available without opengl\n");
- HeapFree(GetProcessHeap(), 0, object->resource.allocatedMemory);
- HeapFree(GetProcessHeap(), 0, object);
- return WINED3DERR_NOTAVAILABLE;
- }
- break;
-
- case SURFACE_GDI:
- object->lpVtbl = &IWineGDISurface_Vtbl;
- break;
-
- default:
- /* To be sure to catch this */
- ERR("Unknown requested surface implementation %d!\n", Impl);
- IWineD3DSurface_Release((IWineD3DSurface *) object);
- return WINED3DERR_INVALIDCALL;
- }
-
list_init(&object->renderbuffers);
/* Call the private setup routine */
- return IWineD3DSurface_PrivateSetup( (IWineD3DSurface *) object );
+ hr = IWineD3DSurface_PrivateSetup((IWineD3DSurface *)object);
+ if (FAILED(hr))
+ {
+ ERR("Private setup failed, returning %#x\n", hr);
+ IWineD3DSurface_Release(*ppSurface);
+ *ppSurface = NULL;
+ return hr;
+ }
+ return hr;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, UINT Width, UINT Height, UINT Levels,
More information about the wine-cvs
mailing list