fixing smaller bugs in cleanup so it remove memory that we alloc, adding more seh around some ore api

svn path=/trunk/; revision=27035
This commit is contained in:
Magnus Olsen 2007-06-07 02:23:54 +00:00
parent 201a7b042d
commit 958b55cf2c
3 changed files with 67 additions and 40 deletions

View file

@ -19,31 +19,38 @@ Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 iface,
REFIID id, REFIID id,
LPVOID *obj) LPVOID *obj)
{ {
HRESULT retVal = DD_OK;
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace(); DX_WINDBG_trace();
/* FIXME _SEH_TRY
the D3D object can be optained from here
Direct3D7
*/
if (IsEqualGUID(&IID_IDirectDraw7, id))
{ {
/* DirectDraw7 Vtable */ /* FIXME
This->lpVtbl = &DirectDraw7_Vtable; the D3D object can be optained from here
This->lpLcl->dwLocalFlags = This->lpLcl->dwLocalFlags + DDRAWILCL_DIRECTDRAW7; Direct3D7
*obj = &This->lpVtbl; */
if (IsEqualGUID(&IID_IDirectDraw7, id))
{
/* DirectDraw7 Vtable */
This->lpVtbl = &DirectDraw7_Vtable;
This->lpLcl->dwLocalFlags = This->lpLcl->dwLocalFlags + DDRAWILCL_DIRECTDRAW7;
*obj = &This->lpVtbl;
Main_DirectDraw_AddRef(iface);
}
else
{
*obj = NULL;
DX_STUB_str("E_NOINTERFACE");
retVal = E_NOINTERFACE;
}
} }
else _SEH_HANDLE
{ {
*obj = NULL;
DX_STUB_str("E_NOINTERFACE");
return E_NOINTERFACE;
} }
_SEH_END;
Main_DirectDraw_AddRef(iface); return retVal;
DX_STUB_str("DD_OK");
return DD_OK;
} }
ULONG WINAPI ULONG WINAPI
@ -88,33 +95,46 @@ Main_DirectDraw_AddRef (LPDIRECTDRAW7 iface)
ULONG WINAPI ULONG WINAPI
Main_DirectDraw_Release (LPDIRECTDRAW7 iface) Main_DirectDraw_Release (LPDIRECTDRAW7 iface)
{ {
ULONG Counter = 0;
LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace(); DX_WINDBG_trace();
_SEH_TRY
if (iface!=NULL)
{ {
This->lpLcl->dwLocalRefCnt--; if (iface!=NULL)
This->dwIntRefCnt--;
if (This->lpLcl->lpGbl != NULL)
{ {
This->lpLcl->lpGbl->dwRefCnt--; This->lpLcl->dwLocalRefCnt--;
} This->dwIntRefCnt--;
if ( This->lpLcl->lpGbl->dwRefCnt == 0) if (This->lpLcl->lpGbl != NULL)
{
// set resoltion back to the one in registry
/*if(This->cooperative_level & DDSCL_EXCLUSIVE)
{ {
ChangeDisplaySettings(NULL, 0); This->lpLcl->lpGbl->dwRefCnt--;
}*/ }
Cleanup(iface); if ( This->lpLcl->lpGbl->dwRefCnt == 0)
return 0; {
// set resoltion back to the one in registry
/*if(This->cooperative_level & DDSCL_EXCLUSIVE)
{
ChangeDisplaySettings(NULL, 0);
}*/
Cleanup(iface);
}
/* FIXME cleanup being not call why ?? */
Counter = This->dwIntRefCnt;
}
else
{
Counter = This->dwIntRefCnt;
} }
} }
return This->dwIntRefCnt; _SEH_HANDLE
{
}
_SEH_END;
return Counter;
} }
HRESULT WINAPI HRESULT WINAPI

View file

@ -15,7 +15,7 @@
VOID VOID
Cleanup(LPDIRECTDRAW7 iface) Cleanup(LPDIRECTDRAW7 iface)
{ {
//LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
DX_WINDBG_trace(); DX_WINDBG_trace();
@ -24,6 +24,11 @@ Cleanup(LPDIRECTDRAW7 iface)
DxHeapMemFree(ddgbl.lpDDCBtmp); DxHeapMemFree(ddgbl.lpDDCBtmp);
} }
if (ddgbl.lpdwFourCC != NULL)
{
DxHeapMemFree(ddgbl.lpdwFourCC);
}
if (ddgbl.lpModeInfo != NULL) if (ddgbl.lpModeInfo != NULL)
{ {
DxHeapMemFree(ddgbl.lpModeInfo); DxHeapMemFree(ddgbl.lpModeInfo);
@ -50,11 +55,10 @@ Cleanup(LPDIRECTDRAW7 iface)
//} //}
/* release unlinked interface */ /* release unlinked interface */
//if (This->lpLcl != NULL) if (This->lpLcl != NULL)
//{ {
// DeleteDC(This->lpLcl->hDC); DxHeapMemFree(This->lpLcl);
// DxHeapMemFree(This->lpLcl); }
//}
//if (This != NULL) //if (This != NULL)
//{ //{
// DxHeapMemFree(This); // DxHeapMemFree(This);

View file

@ -493,7 +493,10 @@ StartDirectDrawHal(LPDIRECTDRAW iface, BOOL reenable)
// if (mHALInfo.ddCaps.dwNumFourCCCodes > 0 ) // if (mHALInfo.ddCaps.dwNumFourCCCodes > 0 )
// { // {
//mpFourCC = (DWORD *) DxHeapMemAlloc( sizeof(DWORD) * 21); //mpFourCC = (DWORD *) DxHeapMemAlloc( sizeof(DWORD) * 21);
// DxHeapMemAlloc(mpFourCC, sizeof(DWORD) * 21); /* DrFred uncomet line 499 see if u getting werid crash in
* u computer, run the ddraw_test around 3-4 times
*/
//DxHeapMemAlloc(mpFourCC, sizeof(DWORD) * 21);
// mpFourCC = (DWORD *) DxHeapMemAlloc(sizeof(DWORD) * (mHALInfo.ddCaps.dwNumFourCCCodes + 2)); // mpFourCC = (DWORD *) DxHeapMemAlloc(sizeof(DWORD) * (mHALInfo.ddCaps.dwNumFourCCCodes + 2));
/* /*