mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 12:49:45 +00:00
gdi32: Use a standard critical section instead of a syslevel for the GDI lock.
This commit is contained in:
parent
20a50f30c4
commit
0d07420ecf
@ -67,14 +67,14 @@ static const LOGPEN DCPen = { PS_SOLID, { 0, 0 }, RGB(0,0,0) };
|
||||
|
||||
static HGDIOBJ stock_objects[NB_STOCK_OBJECTS];
|
||||
|
||||
static SYSLEVEL GDI_level;
|
||||
static CRITICAL_SECTION gdi_section;
|
||||
static CRITICAL_SECTION_DEBUG critsect_debug =
|
||||
{
|
||||
0, 0, &GDI_level.crst,
|
||||
0, 0, &gdi_section,
|
||||
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
||||
0, 0, { (DWORD_PTR)(__FILE__ ": GDI_level") }
|
||||
0, 0, { (DWORD_PTR)(__FILE__ ": gdi_section") }
|
||||
};
|
||||
static SYSLEVEL GDI_level = { { &critsect_debug, -1, 0, 0, 0, 0 }, 3 };
|
||||
static CRITICAL_SECTION gdi_section = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
@ -649,18 +649,18 @@ HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs
|
||||
obj->funcs = funcs;
|
||||
obj->hdcs = NULL;
|
||||
|
||||
_EnterSysLevel( &GDI_level );
|
||||
EnterCriticalSection( &gdi_section );
|
||||
for (i = next_large_handle + 1; i < MAX_LARGE_HANDLES; i++)
|
||||
if (!large_handles[i]) goto found;
|
||||
for (i = 0; i <= next_large_handle; i++)
|
||||
if (!large_handles[i]) goto found;
|
||||
_LeaveSysLevel( &GDI_level );
|
||||
LeaveCriticalSection( &gdi_section );
|
||||
return 0;
|
||||
|
||||
found:
|
||||
large_handles[i] = obj;
|
||||
next_large_handle = i;
|
||||
_LeaveSysLevel( &GDI_level );
|
||||
LeaveCriticalSection( &gdi_section );
|
||||
return (HGDIOBJ)(ULONG_PTR)((i + FIRST_LARGE_HANDLE) << 2);
|
||||
}
|
||||
|
||||
@ -678,10 +678,10 @@ void *free_gdi_handle( HGDIOBJ handle )
|
||||
i = ((ULONG_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
|
||||
if (i >= 0 && i < MAX_LARGE_HANDLES)
|
||||
{
|
||||
_EnterSysLevel( &GDI_level );
|
||||
EnterCriticalSection( &gdi_section );
|
||||
object = large_handles[i];
|
||||
large_handles[i] = NULL;
|
||||
_LeaveSysLevel( &GDI_level );
|
||||
LeaveCriticalSection( &gdi_section );
|
||||
}
|
||||
if (object)
|
||||
{
|
||||
@ -704,7 +704,7 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
|
||||
GDIOBJHDR *ptr = NULL;
|
||||
int i;
|
||||
|
||||
_EnterSysLevel( &GDI_level );
|
||||
EnterCriticalSection( &gdi_section );
|
||||
|
||||
i = ((UINT_PTR)handle >> 2) - FIRST_LARGE_HANDLE;
|
||||
if (i >= 0 && i < MAX_LARGE_HANDLES)
|
||||
@ -715,10 +715,10 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
|
||||
|
||||
if (!ptr)
|
||||
{
|
||||
_LeaveSysLevel( &GDI_level );
|
||||
LeaveCriticalSection( &gdi_section );
|
||||
WARN( "Invalid handle %p\n", handle );
|
||||
}
|
||||
else TRACE("(%p): enter %d\n", handle, GDI_level.crst.RecursionCount);
|
||||
else TRACE("(%p): enter %d\n", handle, gdi_section.RecursionCount);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@ -730,8 +730,8 @@ void *GDI_GetObjPtr( HGDIOBJ handle, WORD type )
|
||||
*/
|
||||
void GDI_ReleaseObj( HGDIOBJ handle )
|
||||
{
|
||||
TRACE("(%p): leave %d\n", handle, GDI_level.crst.RecursionCount);
|
||||
_LeaveSysLevel( &GDI_level );
|
||||
TRACE("(%p): leave %d\n", handle, gdi_section.RecursionCount);
|
||||
LeaveCriticalSection( &gdi_section );
|
||||
}
|
||||
|
||||
|
||||
@ -740,7 +740,11 @@ void GDI_ReleaseObj( HGDIOBJ handle )
|
||||
*/
|
||||
void GDI_CheckNotLock(void)
|
||||
{
|
||||
_CheckNotSysLevel( &GDI_level );
|
||||
if (gdi_section.OwningThread == ULongToHandle(GetCurrentThreadId()) && gdi_section.RecursionCount)
|
||||
{
|
||||
ERR( "BUG: holding GDI lock\n" );
|
||||
DebugBreak();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user