From b597738dd35bf94b8b06414ad6830132ccba9697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Wed, 22 Oct 2003 13:34:25 +0000 Subject: [PATCH] Fix window destruction on thread termination svn path=/trunk/; revision=6400 --- reactos/subsys/win32k/include/dce.h | 8 +++-- reactos/subsys/win32k/include/window.h | 3 +- reactos/subsys/win32k/ntuser/windc.c | 17 +++++------ reactos/subsys/win32k/ntuser/window.c | 41 +++++++++++++++----------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/reactos/subsys/win32k/include/dce.h b/reactos/subsys/win32k/include/dce.h index 9dc5ea31213..0bd81c2ccb9 100644 --- a/reactos/subsys/win32k/include/dce.h +++ b/reactos/subsys/win32k/include/dce.h @@ -3,7 +3,10 @@ /* Ported from WINE by Jason Filby */ +typedef struct tagDCE *PDCE; + #include +#include typedef HANDLE HDCE; @@ -31,8 +34,7 @@ typedef struct tagDCE DCE_TYPE type; DWORD DCXFlags; HANDLE Self; -} DCE, *PDCE; - +} DCE; /* PDCE already declared at top of file */ #define DCEOBJ_AllocDCE() \ ((HDCE) GDIOBJ_AllocObj (sizeof (DCE), GDI_OBJECT_TYPE_DCE, (GDICLEANUPPROC) DCE_InternalDelete)) @@ -50,6 +52,6 @@ BOOL FASTCALL DCE_InvalidateDCE(HWND, const PRECTL); BOOL FASTCALL DCE_InternalDelete(PDCE dce); HWND FASTCALL IntWindowFromDC(HDC hDc); PDCE FASTCALL DceFreeDCE(PDCE dce); -void FASTCALL DceFreeWindowDCE(HWND hwnd); +void FASTCALL DceFreeWindowDCE(PWINDOW_OBJECT Window); #endif diff --git a/reactos/subsys/win32k/include/window.h b/reactos/subsys/win32k/include/window.h index cba215fd07c..32ce76f4874 100644 --- a/reactos/subsys/win32k/include/window.h +++ b/reactos/subsys/win32k/include/window.h @@ -3,6 +3,7 @@ struct _PROPERTY; struct _WINDOW_OBJECT; +typedef struct _WINDOW_OBJECT *PWINDOW_OBJECT; #include #include @@ -92,7 +93,7 @@ typedef struct _WINDOW_OBJECT PETHREAD OwnerThread; HWND hWndOwner; /* handle to the owner window (wine doesn't use pointer, for unk. reason)*/ HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/ -} WINDOW_OBJECT, *PWINDOW_OBJECT; +} WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */ /* Window flags. */ #define WINDOWOBJECT_NEED_SIZE (0x00000001) diff --git a/reactos/subsys/win32k/ntuser/windc.c b/reactos/subsys/win32k/ntuser/windc.c index 53c5730647d..1e8bec92590 100644 --- a/reactos/subsys/win32k/ntuser/windc.c +++ b/reactos/subsys/win32k/ntuser/windc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: windc.c,v 1.33 2003/10/20 17:57:05 gvg Exp $ +/* $Id: windc.c,v 1.34 2003/10/22 13:34:25 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -637,22 +637,21 @@ DceFreeDCE(PDCE dce) * Remove owned DCE and reset unreleased cache DCEs. */ void FASTCALL -DceFreeWindowDCE(HWND hwnd) +DceFreeWindowDCE(PWINDOW_OBJECT Window) { DCE *pDCE; - PWINDOW_OBJECT pWnd = IntGetWindowObject(hwnd); pDCE = FirstDce; while (pDCE) { - if (pDCE->hwndCurrent == hwnd) + if (pDCE->hwndCurrent == Window->Self) { - if (pDCE == pWnd->Dce) /* owned or Class DCE*/ + if (pDCE == Window->Dce) /* owned or Class DCE*/ { - if (pWnd->Class->style & CS_OWNDC) /* owned DCE*/ + if (Window->Class->style & CS_OWNDC) /* owned DCE*/ { pDCE = DceFreeDCE(pDCE); - pWnd->Dce = NULL; + Window->Dce = NULL; continue; } else if (pDCE->DCXFlags & (DCX_INTERSECTRGN | DCX_EXCLUDERGN)) /* Class DCE*/ @@ -672,7 +671,7 @@ DceFreeWindowDCE(HWND hwnd) * We should change this to DPRINT when ReactOS is more stable * (for 1.0?). */ - DPRINT1("[%p] GetDC() without ReleaseDC()!\n", hwnd); + DPRINT1("[%p] GetDC() without ReleaseDC()!\n", Window->Self); DceReleaseDC(pDCE); } @@ -683,8 +682,6 @@ DceFreeWindowDCE(HWND hwnd) } pDCE = pDCE->next; } - - IntReleaseWindowObject(pWnd); } /* EOF */ diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 883ab43cd25..e808d6780ac 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.115 2003/10/18 10:35:52 navaraf Exp $ +/* $Id: window.c,v 1.116 2003/10/22 13:34:25 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -101,6 +101,26 @@ inline BOOL IntIsDesktopWindow(PWINDOW_OBJECT Wnd) } +static PWINDOW_OBJECT FASTCALL +IntGetProcessWindowObject(PW32PROCESS ProcessData, HWND hWnd) +{ + PWINDOW_OBJECT WindowObject; + NTSTATUS Status; + + Status = + ObmReferenceObjectByHandle(ProcessData->WindowStation-> + HandleTable, + hWnd, + otWindow, + (PVOID*)&WindowObject); + if (!NT_SUCCESS(Status)) + { + return(NULL); + } + return(WindowObject); +} + + static BOOL BuildChildWindowArray(PWINDOW_OBJECT Window, HWND **Children, unsigned *NumChildren) { unsigned Index; @@ -172,7 +192,7 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window, } for (Index = NumChildren; 0 < Index; Index--) { - Child = IntGetWindowObject(Children[Index - 1]); + Child = IntGetProcessWindowObject(ProcessData, Children[Index - 1]); if (NULL != Child) { if (IntWndBelongsToThread(Child, ThreadData)) @@ -243,7 +263,7 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window, Window->hSysMenu = 0; } #endif - DceFreeWindowDCE(Window->Self); /* Always do this to catch orphaned DCs */ + DceFreeWindowDCE(Window); /* Always do this to catch orphaned DCs */ #if 0 /* FIXME */ WINPROC_FreeProc(Window->winproc, WIN_PROC_WINDOW); CLASS_RemoveWindow(Window->Class); @@ -540,20 +560,7 @@ IntGetSystemMenu(PWINDOW_OBJECT WindowObject, BOOL bRevert, BOOL RetMenu) PWINDOW_OBJECT FASTCALL IntGetWindowObject(HWND hWnd) { - PWINDOW_OBJECT WindowObject; - NTSTATUS Status; - - Status = - ObmReferenceObjectByHandle(PsGetWin32Process()->WindowStation-> - HandleTable, - hWnd, - otWindow, - (PVOID*)&WindowObject); - if (!NT_SUCCESS(Status)) - { - return(NULL); - } - return(WindowObject); + return IntGetProcessWindowObject(PsGetWin32Process(), hWnd); }