Commit 9ff44b81 authored by Alexandre Julliard's avatar Alexandre Julliard

gdi32: Don't hold the GDI lock while calling the UnrealizeObject method for GDI objects.

parent f0387109
......@@ -74,7 +74,7 @@ struct gdi_obj_funcs
HGDIOBJ (*pSelectObject)( HGDIOBJ handle, HDC hdc );
INT (*pGetObjectA)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
INT (*pGetObjectW)( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
BOOL (*pUnrealizeObject)( HGDIOBJ handle, void *obj );
BOOL (*pUnrealizeObject)( HGDIOBJ handle );
BOOL (*pDeleteObject)( HGDIOBJ handle );
};
......
......@@ -1145,20 +1145,19 @@ HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ hObj )
*/
BOOL WINAPI UnrealizeObject( HGDIOBJ obj )
{
BOOL result = TRUE;
/* Check if object is valid */
BOOL result = FALSE;
GDIOBJHDR * header = GDI_GetObjPtr( obj, MAGIC_DONTCARE );
if (!header) return FALSE;
TRACE("%p\n", obj );
/* Unrealize object */
if (header->funcs && header->funcs->pUnrealizeObject)
result = header->funcs->pUnrealizeObject( obj, header );
if (header)
{
const struct gdi_obj_funcs *funcs = header->funcs;
GDI_ReleaseObj( obj );
GDI_ReleaseObj( obj );
if (funcs && funcs->pUnrealizeObject)
result = header->funcs->pUnrealizeObject( obj );
else
result = TRUE;
}
return result;
}
......
......@@ -46,7 +46,7 @@ typedef struct tagPALETTEOBJ
} PALETTEOBJ;
static INT PALETTE_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer );
static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle, void *obj );
static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle );
static BOOL PALETTE_DeleteObject( HGDIOBJ handle );
static const struct gdi_obj_funcs palette_funcs =
......@@ -374,12 +374,11 @@ BOOL WINAPI ResizePalette(
if (!(palPtr = GDI_ReallocObject( size, hPal, palPtr ))) return FALSE;
PALETTE_UnrealizeObject( hPal, palPtr );
if( cEntries > cPrevEnt ) memset( (BYTE*)palPtr + prevsize, 0, size - prevsize );
palPtr->logpalette.palNumEntries = cEntries;
palPtr->logpalette.palVersion = prevVer;
GDI_ReleaseObj( hPal );
PALETTE_UnrealizeObject( hPal );
return TRUE;
}
......@@ -647,15 +646,16 @@ static INT PALETTE_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffe
/***********************************************************************
* PALETTE_UnrealizeObject
*/
static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle, void *obj )
static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle )
{
PALETTEOBJ *palette = obj;
PALETTEOBJ *palette = GDI_GetObjPtr( handle, PALETTE_MAGIC );
if (palette->funcs)
if (palette)
{
if (palette->funcs->pUnrealizePalette)
palette->funcs->pUnrealizePalette( handle );
const DC_FUNCTIONS *funcs = palette->funcs;
palette->funcs = NULL;
GDI_ReleaseObj( handle );
if (funcs && funcs->pUnrealizePalette) funcs->pUnrealizePalette( handle );
}
if (InterlockedCompareExchangePointer( (void **)&hLastRealizedPalette, 0, handle ) == handle)
......@@ -670,10 +670,10 @@ static BOOL PALETTE_UnrealizeObject( HGDIOBJ handle, void *obj )
*/
static BOOL PALETTE_DeleteObject( HGDIOBJ handle )
{
PALETTEOBJ *obj = GDI_GetObjPtr( handle, PALETTE_MAGIC );
PALETTEOBJ *obj;
if (!obj) return FALSE;
PALETTE_UnrealizeObject( handle, obj );
PALETTE_UnrealizeObject( handle );
if (!(obj = GDI_GetObjPtr( handle, PALETTE_MAGIC ))) return FALSE;
return GDI_FreeObject( handle, obj );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment