From 7110c88cc07f915e7d9ae826319986d5cf3156ef Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 2 Mar 2011 22:33:14 +0000 Subject: [PATCH 1/1] [WIN32K] Revert part of r50941. First its architecturally unclean to lock a DC in a USER function, 2nd its a bug to keep the lock while sending a message. svn path=/trunk/; revision=50959 --- .../subsystems/win32/win32k/include/color.h | 2 +- .../subsystems/win32/win32k/ntuser/painting.c | 7 +------ .../subsystems/win32/win32k/objects/palette.c | 20 +++++++++++++++---- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/reactos/subsystems/win32/win32k/include/color.h b/reactos/subsystems/win32/win32k/include/color.h index faf88a77eee..233412e6ccd 100644 --- a/reactos/subsystems/win32/win32k/include/color.h +++ b/reactos/subsystems/win32/win32k/include/color.h @@ -36,6 +36,6 @@ const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate (VOID); COLORREF APIENTRY COLOR_LookupNearestColor (PALETTEENTRY* palPalEntry, INT size, COLORREF color); INT APIENTRY COLOR_PaletteLookupExactIndex (PALETTEENTRY* palPalEntry, INT size, COLORREF col); INT APIENTRY COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, XLATEOBJ *XlateObj, COLORREF col, BOOL skipReserved); -UINT FASTCALL IntGdiRealizePalette (PDC); +UINT FASTCALL IntGdiRealizePalette (HDC); HCOLORSPACE FASTCALL IntGdiCreateColorSpace(PLOGCOLORSPACEEXW); BOOL FASTCALL IntGdiDeleteColorSpace(HCOLORSPACE); diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index 8692a036a4b..f2e3850437f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -1951,11 +1951,7 @@ UserRealizePalette(HDC hdc) HWND hWnd; DWORD Ret; - PDC pdc = DC_LockDc(hdc); - if(!pdc) - return 0; - - Ret = IntGdiRealizePalette(pdc); + Ret = IntGdiRealizePalette(hdc); if (Ret) // There was a change. { hWnd = IntWindowFromDC(hdc); @@ -1964,7 +1960,6 @@ UserRealizePalette(HDC hdc) UserSendNotifyMessage((HWND)HWND_BROADCAST, WM_PALETTECHANGED, (WPARAM)hWnd, 0); } } - DC_UnlockDc(pdc); return Ret; } diff --git a/reactos/subsystems/win32/win32k/objects/palette.c b/reactos/subsystems/win32/win32k/objects/palette.c index 59b16430303..c7656e03d1c 100644 --- a/reactos/subsystems/win32/win32k/objects/palette.c +++ b/reactos/subsystems/win32/win32k/objects/palette.c @@ -723,18 +723,26 @@ NtGdiGetNearestPaletteIndex( UINT FASTCALL -IntGdiRealizePalette(PDC pdc) +IntGdiRealizePalette(HDC hDC) { UINT i, realize = 0; + PDC pdc; PALETTE *ppalSurf, *ppalDC; + pdc = DC_LockDc(hDC); + if(!pdc) + { + EngSetLastError(ERROR_INVALID_HANDLE); + return 0; + } + ppalSurf = pdc->dclevel.pSurface->ppal; ppalDC = pdc->dclevel.ppal; if(!(ppalSurf->flFlags & PAL_INDEXED)) { // FIXME : set error? - return 0; + goto cleanup; } ASSERT(ppalDC->flFlags & PAL_INDEXED); @@ -747,6 +755,8 @@ IntGdiRealizePalette(PDC pdc) InterlockedExchange((LONG*)&ppalSurf->IndexedColors[i], *(LONG*)&ppalDC->IndexedColors[i]); } +cleanup: + DC_UnlockDc(pdc); return realize; } @@ -800,9 +810,11 @@ IntAnimatePalette(HPALETTE hPal, { if (dc->dclevel.hpal == hPal) { - IntGdiRealizePalette(dc); + DC_UnlockDc(dc); + IntGdiRealizePalette(hDC); } - DC_UnlockDc(dc); + else + DC_UnlockDc(dc); } UserReleaseDC(Wnd,hDC, FALSE); } -- 2.17.1