[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 2 Mar 2011 22:33:14 +0000 (22:33 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 2 Mar 2011 22:33:14 +0000 (22:33 +0000)
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

reactos/subsystems/win32/win32k/include/color.h
reactos/subsystems/win32/win32k/ntuser/painting.c
reactos/subsystems/win32/win32k/objects/palette.c

index faf88a7..233412e 100644 (file)
@@ -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);
index 8692a03..f2e3850 100644 (file)
@@ -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;
 }
 
index 59b1643..c7656e0 100644 (file)
@@ -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);
     }