From 3fd1dcd5e0dee669838bf6c47ed96a632bb8148f Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Wed, 24 Sep 2003 16:01:32 +0000 Subject: [PATCH] some fixes on on gdi handles svn path=/trunk/; revision=6120 --- reactos/subsys/win32k/ntuser/windc.c | 16 ++++++++++++---- reactos/subsys/win32k/objects/cliprgn.c | 7 +++++-- reactos/subsys/win32k/objects/gdiobj.c | 25 +++++++++++++------------ reactos/subsys/win32k/objects/text.c | 15 ++++++++++++--- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/reactos/subsys/win32k/ntuser/windc.c b/reactos/subsys/win32k/ntuser/windc.c index 239294769b6..df7f15e0e31 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.23 2003/09/09 09:39:21 gvg Exp $ +/* $Id: windc.c,v 1.24 2003/09/24 16:01:32 weiden Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -132,6 +132,9 @@ PDCE FASTCALL DceAllocDCE(HWND hWnd, DCE_TYPE Type) DCE* Dce; DceHandle = DCEOBJ_AllocDCE(); + if(!DceHandle) + return NULL; + Dce = DCEOBJ_LockDCE(DceHandle); Dce->hDC = NtGdiCreateDC(L"DISPLAY", NULL, NULL, NULL); Dce->hwndCurrent = hWnd; @@ -171,6 +174,9 @@ DceSetDrawable(PWINDOW_OBJECT WindowObject, HDC hDC, ULONG Flags, BOOL SetClipOrigin) { DC *dc = DC_LockDc(hDC); + if(!dc) + return; + if (WindowObject == NULL) { dc->w.DCOrgX = 0; @@ -342,9 +348,10 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) DbgBreakPoint(); } - if (NULL == Dce && NULL != Window) + if (NULL == Dce) { - IntReleaseWindowObject(Window); + if(NULL != Window) + IntReleaseWindowObject(Window); return(NULL); } @@ -366,7 +373,8 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags) if (NULL != ClipRegion) { Dce->hClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); - NtGdiCombineRgn(Dce->hClipRgn, ClipRegion, NULL, RGN_COPY); + if(Dce->hClipRgn) + NtGdiCombineRgn(Dce->hClipRgn, ClipRegion, NULL, RGN_COPY); NtGdiDeleteObject(ClipRegion); } diff --git a/reactos/subsys/win32k/objects/cliprgn.c b/reactos/subsys/win32k/objects/cliprgn.c index 37537fb26b1..eb635f49a2b 100644 --- a/reactos/subsys/win32k/objects/cliprgn.c +++ b/reactos/subsys/win32k/objects/cliprgn.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: cliprgn.c,v 1.24 2003/09/09 09:39:21 gvg Exp $ */ +/* $Id: cliprgn.c,v 1.25 2003/09/24 16:01:32 weiden Exp $ */ #undef WIN32_LEAN_AND_MEAN #include @@ -58,7 +58,10 @@ CLIPPING_UpdateGCRegion(DC* Dc) #endif Combined = NtGdiCreateRectRgn(0, 0, 0, 0); - ASSERT(NULL != Combined); + if(!Combined) + { + return; + } if (Dc->w.hClipRgn == NULL) { diff --git a/reactos/subsys/win32k/objects/gdiobj.c b/reactos/subsys/win32k/objects/gdiobj.c index 5920ba87a10..fb61119f9b0 100644 --- a/reactos/subsys/win32k/objects/gdiobj.c +++ b/reactos/subsys/win32k/objects/gdiobj.c @@ -19,7 +19,7 @@ /* * GDIOBJ.C - GDI object manipulation routines * - * $Id: gdiobj.c,v 1.42 2003/09/23 18:04:42 gvg Exp $ + * $Id: gdiobj.c,v 1.43 2003/09/24 16:01:32 weiden Exp $ * */ @@ -223,8 +223,16 @@ HGDIOBJ FASTCALL GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) { PGDIOBJHDR newObject; + WORD Index; + + Index = GDIOBJ_iGetNextOpenHandleIndex (); + if (0 == Index) + { + DPRINT1("Out of GDI handles\n"); + return NULL; + } - DPRINT("GDIOBJ_AllocObj: size: %d, type: 0x%08x\n", Size, ObjectType); + DPRINT("GDIOBJ_AllocObj: handle: %d, size: %d, type: 0x%08x\n", Index, Size, ObjectType); newObject = ExAllocatePool(PagedPool, Size + sizeof (GDIOBJHDR)); if (newObject == NULL) { @@ -233,14 +241,7 @@ GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) } RtlZeroMemory (newObject, Size + sizeof(GDIOBJHDR)); - newObject->wTableIndex = GDIOBJ_iGetNextOpenHandleIndex (); - DPRINT("GDIOBJ_AllocObj: object handle %d\n", newObject->wTableIndex ); - if (0 == newObject->wTableIndex) - { - DPRINT1("Out of GDI handles\n"); - ExFreePool(newObject); - return NULL; - } + newObject->wTableIndex = Index; newObject->dwCount = 0; newObject->hProcessId = PsGetCurrentProcessId (); @@ -248,9 +249,9 @@ GDIOBJ_AllocObj(WORD Size, DWORD ObjectType, GDICLEANUPPROC CleanupProc) newObject->Magic = GDI_TYPE_TO_MAGIC(ObjectType); newObject->lockfile = NULL; newObject->lockline = 0; - HandleTable->Handles[newObject->wTableIndex] = newObject; + HandleTable->Handles[Index] = newObject; - return GDI_HANDLE_CREATE(newObject->wTableIndex, ObjectType); + return GDI_HANDLE_CREATE(Index, ObjectType); } /*! diff --git a/reactos/subsys/win32k/objects/text.c b/reactos/subsys/win32k/objects/text.c index 61948c82206..d71ac29407f 100644 --- a/reactos/subsys/win32k/objects/text.c +++ b/reactos/subsys/win32k/objects/text.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: text.c,v 1.51 2003/09/10 23:16:13 gvg Exp $ */ +/* $Id: text.c,v 1.52 2003/09/24 16:01:32 weiden Exp $ */ #undef WIN32_LEAN_AND_MEAN @@ -1032,7 +1032,7 @@ NtGdiTextOut(HDC hDC, { // Fixme: Call EngTextOut, which does the real work (calling DrvTextOut where appropriate) - DC *dc = DC_LockDc(hDC); + DC *dc; SURFOBJ *SurfObj; int error, glyph_index, n, i; FT_Face face; @@ -1057,6 +1057,7 @@ NtGdiTextOut(HDC hDC, PXLATEOBJ XlateObj; ULONG Mode; + dc = DC_LockDc(hDC); if( !dc ) return FALSE; SurfObj = (SURFOBJ*)AccessUserObject((ULONG) dc->Surface); @@ -1116,7 +1117,15 @@ NtGdiTextOut(HDC hDC, if (OPAQUE == dc->w.backgroundMode) { hBrushBg = NtGdiCreateSolidBrush(XLATEOBJ_iXlate(XlateObj, dc->w.backgroundColor)); - BrushBg = BRUSHOBJ_LockBrush(hBrushBg); + if(hBrushBg) + { + BrushBg = BRUSHOBJ_LockBrush(hBrushBg); + } + else + { + EngDeleteXlate(XlateObj); + goto fail; + } } EngDeleteXlate(XlateObj);