Check if DC is busy before deleting it.

This commit is contained in:
Francis Beaudet 1999-05-04 16:55:22 +00:00 committed by Alexandre Julliard
parent 99920819a5
commit 179e8deb6d
3 changed files with 44 additions and 1 deletions

View File

@ -53,5 +53,6 @@ extern void DCE_FreeWindowDCE( WND* );
extern INT16 DCE_ExcludeRgn( HDC, WND*, HRGN );
extern HRGN DCE_GetVisRgn( HWND, WORD, HWND, WORD );
extern BOOL DCE_InvalidateDCE( WND*, const RECT* );
extern BOOL DCE_IsDCBusy(HDC hdc);
#endif /* __WINE_DCE_H */

View File

@ -657,7 +657,20 @@ BOOL16 WINAPI DeleteDC16( HDC16 hdc )
*/
BOOL WINAPI DeleteDC( HDC hdc )
{
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
DC * dc;
/*
* Windows will not let you delete a DC that is busy
* (between GetDC and ReleaseDC)
*/
if (DCE_IsDCBusy(hdc))
{
WARN(dc, " Application trying to delete a busy DC\n");
return TRUE;
}
dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return FALSE;
TRACE(dc, "%04x\n", hdc );

View File

@ -627,6 +627,35 @@ INT16 DCE_ExcludeRgn( HDC hDC, WND* wnd, HRGN hRgn )
return ExtSelectClipRgn( hDC, hRgn, RGN_DIFF );
}
/***********************************************************************
* DCE_IsDCBusy
*
* Utility function to determine if a particular DC is currently
* in a busy state..
*/
BOOL DCE_IsDCBusy(HDC hdc)
{
DCE* dce;
BOOL isBusy = FALSE;
WIN_LockWnds();
dce = firstDCE;
while (dce && (dce->hDC != hdc)) dce = dce->next;
if ( dce )
{
if ( dce->DCXflags & DCX_DCEBUSY )
{
isBusy = TRUE;
}
}
WIN_UnlockWnds();
return isBusy;
}
/***********************************************************************
* GetDCEx16 (USER.359)
*/