From 179e8deb6dd342d6038fe31dc0bd5520b446d921 Mon Sep 17 00:00:00 2001 From: Francis Beaudet Date: Tue, 4 May 1999 16:55:22 +0000 Subject: [PATCH] Check if DC is busy before deleting it. --- include/dce.h | 1 + objects/dc.c | 15 ++++++++++++++- windows/dce.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/include/dce.h b/include/dce.h index 3fa10cb555..2f7cae4b2d 100644 --- a/include/dce.h +++ b/include/dce.h @@ -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 */ diff --git a/objects/dc.c b/objects/dc.c index 560378d59f..7c746ed102 100644 --- a/objects/dc.c +++ b/objects/dc.c @@ -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 ); diff --git a/windows/dce.c b/windows/dce.c index aba47dff56..c8979a5656 100644 --- a/windows/dce.c +++ b/windows/dce.c @@ -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) */ -- 2.32.0.93.g670b81a890