Author: jimtabor Date: Tue Feb 23 16:42:08 2010 New Revision: 45671
URL: http://svn.reactos.org/svn/reactos?rev=45671&view=rev Log: [Win32k] - If dc is window owned and not class owned do not set class if null pdce. Added debug prints to locate reentrancy issues due to a race condition. - Add more checks to find dead windows.
Modified: trunk/reactos/subsystems/win32/win32k/include/dce.h trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c trunk/reactos/subsystems/win32/win32k/ntuser/vis.c trunk/reactos/subsystems/win32/win32k/ntuser/windc.c trunk/reactos/subsystems/win32/win32k/ntuser/window.c
Modified: trunk/reactos/subsystems/win32/win32k/include/dce.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/inc... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/dce.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/dce.h [iso-8859-1] Tue Feb 23 16:42:08 2010 @@ -48,6 +48,7 @@ #define DCX_DCPOWNED 0x00008000 #define DCX_NOCLIPCHILDREN 0x00080000 #define DCX_NORECOMPUTE 0x00100000 +#define DCX_INDESTROY 0x00400000
BOOL FASTCALL DCE_Cleanup(PDCE pDce); PDCE FASTCALL DceAllocDCE(PWINDOW_OBJECT Window, DCE_TYPE Type);
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] Tue Feb 23 16:42:08 2010 @@ -238,7 +238,7 @@ * User32 macro NtUserShowCursor */ int UserShowCursor(BOOL bShow) { - PSYSTEM_CURSORINFO CurInfo = IntGetSysCursorInfo();; + PSYSTEM_CURSORINFO CurInfo = IntGetSysCursorInfo(); HDC hdcScreen;
if (!(hdcScreen = IntGetScreenDC()))
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/vis.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/vis.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/vis.c [iso-8859-1] Tue Feb 23 16:42:08 2010 @@ -92,7 +92,9 @@ (PreviousWnd == Wnd && ClipSiblings)) { CurrentSibling = CurrentWindow->spwndChild; - while (CurrentSibling != NULL && CurrentSibling != PreviousWindow) + while ( CurrentSibling != NULL && + CurrentSibling != PreviousWindow && + CurrentSibling->Wnd ) { CurrentSiblingWnd = CurrentSibling->Wnd; if ((CurrentSiblingWnd->style & WS_VISIBLE) && @@ -121,7 +123,7 @@ if (ClipChildren) { CurrentWindow = Window->spwndChild; - while (CurrentWindow) + while (CurrentWindow && CurrentWindow->Wnd) { CurrentWnd = CurrentWindow->Wnd; if ((CurrentWnd->style & WS_VISIBLE) &&
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/windc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/windc.c [iso-8859-1] Tue Feb 23 16:42:08 2010 @@ -181,7 +181,7 @@ } else if (Dce->hrgnClip != NULL) { - REGION_FreeRgnByHandle(Dce->hrgnClip); + GDIOBJ_FreeObjByHandle(Dce->hrgnClip, GDI_OBJECT_TYPE_REGION|GDI_OBJECT_TYPE_SILENT); }
Dce->hrgnClip = NULL; @@ -193,7 +193,7 @@ static INT FASTCALL DceReleaseDC(DCE* dce, BOOL EndPaint) { - if (DCX_DCEBUSY != (dce->DCXFlags & (DCX_DCEEMPTY | DCX_DCEBUSY))) + if (DCX_DCEBUSY != (dce->DCXFlags & (DCX_INDESTROY | DCX_DCEEMPTY | DCX_DCEBUSY))) { return 0; } @@ -573,6 +573,12 @@ } else if (ClipRegion != NULL) { + if (Dce->hrgnClip != NULL) + { + DPRINT1("Should not be called!!\n"); + GDIOBJ_FreeObjByHandle(Dce->hrgnClip, GDI_OBJECT_TYPE_REGION|GDI_OBJECT_TYPE_SILENT); + Dce->hrgnClip = NULL; + } Dce->hrgnClip = ClipRegion; }
@@ -620,6 +626,8 @@
pLE = pdce->List.Flink; ret = CONTAINING_RECORD(pLE, DCE, List); + + pdce->DCXFlags |= DCX_INDESTROY;
if (Force && !GDIOBJ_OwnedByCurrentProcess(pdce->hDC)) { @@ -638,9 +646,9 @@
if (!Hit) IntGdiDeleteDC(pdce->hDC, TRUE);
- if (pdce->hrgnClip && ! (pdce->DCXFlags & DCX_KEEPCLIPRGN)) - { - REGION_FreeRgnByHandle(pdce->hrgnClip); + if (pdce->hrgnClip && !(pdce->DCXFlags & DCX_KEEPCLIPRGN)) + { + GDIOBJ_FreeObjByHandle(pdce->hrgnClip, GDI_OBJECT_TYPE_REGION|GDI_OBJECT_TYPE_SILENT); pdce->hrgnClip = NULL; }
@@ -673,7 +681,7 @@
if (DCECount <= 0) { - DPRINT1("No Entry!\n"); + DPRINT1("FreeWindowDCE No Entry! %d\n",DCECount); return; }
@@ -681,8 +689,16 @@ pDCE = CONTAINING_RECORD(pLE, DCE, List); do { - if (!pDCE) break; - if (IsListEmpty(&pDCE->List)) break; + if (!pDCE) + { + DPRINT1("FreeWindowDCE No DCE Pointer!\n"); + break; + } + if (IsListEmpty(&pDCE->List)) + { + DPRINT1("FreeWindowDCE List is Empty!!!!\n"); + break; + } if ( pDCE->hwndCurrent == Window->hSelf && !(pDCE->DCXFlags & DCX_DCEEMPTY) ) { @@ -700,7 +716,10 @@
DPRINT("POWNED DCE going Cheap!! DCX_CACHE!! hDC-> %x \n", pDCE->hDC); if (!IntGdiSetDCOwnerEx( pDCE->hDC, GDI_OBJ_HMGR_NONE, FALSE)) - return; + { + DPRINT1("Fail Owner Switch hDC-> %x \n", pDCE->hDC); + break; + } /* Do not change owner so thread can clean up! */ } else if (Window->Wnd->pcls->style & CS_OWNDC) /* owned DCE*/ @@ -711,6 +730,7 @@ } else { + DPRINT1("Not POWNED or CLASSDC hwndCurrent -> %x \n", pDCE->hwndCurrent); ASSERT(FALSE); } } @@ -825,7 +845,7 @@ { if(!pDCE) break; if(pLE == &LEDce) break; - if (0 == (pDCE->DCXFlags & DCX_DCEEMPTY)) + if (0 == (pDCE->DCXFlags & (DCX_DCEEMPTY|DCX_INDESTROY))) { if (Window->hSelf == pDCE->hwndCurrent) { @@ -902,9 +922,12 @@ Dce = CONTAINING_RECORD(pLE, DCE, List); do { - if(Dce->hDC == hDc) - { - Ret = Dce->hwndCurrent; + if (Dce->hDC == hDc) + { + if (Dce->DCXFlags & DCX_INDESTROY) + Ret = NULL; + else + Ret = Dce->hwndCurrent; break; } pLE = Dce->List.Flink;
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Tue Feb 23 16:42:08 2010 @@ -2057,9 +2057,7 @@ } else if ( Wnd->pcls->style & CS_OWNDC) { /* Allocate a DCE for this window. */ - PDCE pDce = DceAllocDCE(Window, DCE_WINDOW_DC); - if (!Wnd->pcls->pdce) - Wnd->pcls->pdce = pDce; + DceAllocDCE(Window, DCE_WINDOW_DC); }
Pos.x = x;