From 0086d490a92594be0faf3f680346a16caa26f710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Sun, 20 May 2007 23:51:26 +0200 Subject: [PATCH] ddraw: Hold the lock in IDirectDrawClipper methods. --- dlls/ddraw/clipper.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/dlls/ddraw/clipper.c b/dlls/ddraw/clipper.c index eb8a8dbd530..517bc7c49bc 100644 --- a/dlls/ddraw/clipper.c +++ b/dlls/ddraw/clipper.c @@ -106,8 +106,10 @@ static ULONG WINAPI IDirectDrawClipperImpl_Release(IDirectDrawClipper *iface) { if (ref == 0) { + EnterCriticalSection(&ddraw_cs); IWineD3DClipper_Release(This->wineD3DClipper); HeapFree(GetProcessHeap(), 0, This); + LeaveCriticalSection(&ddraw_cs); return 0; } else return ref; @@ -135,9 +137,11 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetHwnd( HRESULT hr; TRACE("(%p)->(%08x,%p)\n", This, dwFlags, hWnd); + EnterCriticalSection(&ddraw_cs); hr = IWineD3DClipper_SetHWnd(This->wineD3DClipper, dwFlags, hWnd); + LeaveCriticalSection(&ddraw_cs); switch(hr) { case WINED3DERR_INVALIDCALL: return DDERR_INVALIDPARAMS; @@ -168,12 +172,16 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetClipList( LPDWORD lpdwSize) { IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + HRESULT hr; TRACE("(%p,%p,%p,%p)\n", This, lpRect, lpClipList, lpdwSize); - return IWineD3DClipper_GetClipList(This->wineD3DClipper, - lpRect, - lpClipList, - lpdwSize); + EnterCriticalSection(&ddraw_cs); + hr = IWineD3DClipper_GetClipList(This->wineD3DClipper, + lpRect, + lpClipList, + lpdwSize); + LeaveCriticalSection(&ddraw_cs); + return hr; } /***************************************************************************** @@ -194,10 +202,14 @@ static HRESULT WINAPI IDirectDrawClipperImpl_SetClipList( LPDIRECTDRAWCLIPPER iface,LPRGNDATA lprgn,DWORD dwFlag ) { IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + HRESULT hr; - return IWineD3DClipper_SetClipList(This->wineD3DClipper, - lprgn, - dwFlag); + EnterCriticalSection(&ddraw_cs); + hr = IWineD3DClipper_SetClipList(This->wineD3DClipper, + lprgn, + dwFlag); + LeaveCriticalSection(&ddraw_cs); + return hr; } /***************************************************************************** @@ -215,10 +227,14 @@ static HRESULT WINAPI IDirectDrawClipperImpl_GetHWnd( LPDIRECTDRAWCLIPPER iface, HWND* hWndPtr ) { IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; + HRESULT hr; TRACE("(%p)->(%p)\n", This, hWndPtr); - return IWineD3DClipper_GetHWnd(This->wineD3DClipper, - hWndPtr); + EnterCriticalSection(&ddraw_cs); + hr = IWineD3DClipper_GetHWnd(This->wineD3DClipper, + hWndPtr); + LeaveCriticalSection(&ddraw_cs); + return hr; } /***************************************************************************** @@ -242,11 +258,17 @@ static HRESULT WINAPI IDirectDrawClipperImpl_Initialize( IDirectDrawClipperImpl *This = (IDirectDrawClipperImpl *)iface; TRACE("(%p)->(%p,0x%08x)\n", This, lpDD, dwFlags); - if (This->ddraw_owner != NULL) return DDERR_ALREADYINITIALIZED; + EnterCriticalSection(&ddraw_cs); + if (This->ddraw_owner != NULL) + { + LeaveCriticalSection(&ddraw_cs); + return DDERR_ALREADYINITIALIZED; + } pOwner = ICOM_OBJECT(IDirectDrawImpl, IDirectDraw, lpDD); This->ddraw_owner = pOwner; + LeaveCriticalSection(&ddraw_cs); return DD_OK; }