Alexandre Julliard : gdi32: Use a standard critical section instead of a syslevel for the GDI lock.

Alexandre Julliard julliard at winehq.org
Mon Dec 28 09:16:02 CST 2009


Module: wine
Branch: master
Commit: 0d07420ecf920142ba0f6aea80d7140c3ddc6df6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0d07420ecf920142ba0f6aea80d7140c3ddc6df6

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Dec 24 17:42:13 2009 +0100

gdi32: Use a standard critical section instead of a syslevel for the GDI lock.

---

 dlls/gdi32/gdiobj.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index 245b1cc..d32450a 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -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();
+    }
 }
 
 




More information about the wine-cvs mailing list