Jacek Caban : winemac: Use pthread for cursor cache locking.

Alexandre Julliard julliard at winehq.org
Wed May 18 15:38:30 CDT 2022


Module: wine
Branch: master
Commit: 3ab98869bb983bc02aafcaead0b802d4ae585697
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3ab98869bb983bc02aafcaead0b802d4ae585697

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue May 17 01:16:59 2022 +0200

winemac: Use pthread for cursor cache locking.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winemac.drv/mouse.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/dlls/winemac.drv/mouse.c b/dlls/winemac.drv/mouse.c
index 55bed52ae8e..d101d2513c8 100644
--- a/dlls/winemac.drv/mouse.c
+++ b/dlls/winemac.drv/mouse.c
@@ -32,15 +32,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(cursor);
 
 
-static CRITICAL_SECTION cursor_cache_section;
-static CRITICAL_SECTION_DEBUG critsect_debug =
-{
-    0, 0, &cursor_cache_section,
-    { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
-      0, 0, { (DWORD_PTR)(__FILE__ ": cursor_cache_section") }
-};
-static CRITICAL_SECTION cursor_cache_section = { &critsect_debug, -1, 0, 0, 0, 0 };
-
+static pthread_mutex_t cursor_cache_mutex = PTHREAD_MUTEX_INITIALIZER;
 static CFMutableDictionaryRef cursor_cache;
 
 
@@ -647,10 +639,10 @@ void macdrv_DestroyCursorIcon(HCURSOR cursor)
 {
     TRACE("cursor %p\n", cursor);
 
-    EnterCriticalSection(&cursor_cache_section);
+    pthread_mutex_lock(&cursor_cache_mutex);
     if (cursor_cache)
         CFDictionaryRemoveValue(cursor_cache, cursor);
-    LeaveCriticalSection(&cursor_cache_section);
+    pthread_mutex_unlock(&cursor_cache_mutex);
 }
 
 
@@ -731,7 +723,7 @@ void macdrv_SetCursor(HCURSOR cursor)
     {
         ICONINFOEXW info;
 
-        EnterCriticalSection(&cursor_cache_section);
+        pthread_mutex_lock(&cursor_cache_mutex);
         if (cursor_cache)
         {
             CFTypeRef cached_cursor = CFDictionaryGetValue(cursor_cache, cursor);
@@ -743,7 +735,7 @@ void macdrv_SetCursor(HCURSOR cursor)
                     cursor_frames = CFRetain(cached_cursor);
             }
         }
-        LeaveCriticalSection(&cursor_cache_section);
+        pthread_mutex_unlock(&cursor_cache_mutex);
         if (cursor_name || cursor_frames)
             goto done;
 
@@ -790,13 +782,13 @@ void macdrv_SetCursor(HCURSOR cursor)
 
         if (cursor_name || cursor_frames)
         {
-            EnterCriticalSection(&cursor_cache_section);
+            pthread_mutex_lock(&cursor_cache_mutex);
             if (!cursor_cache)
                 cursor_cache = CFDictionaryCreateMutable(NULL, 0, NULL,
                                                          &kCFTypeDictionaryValueCallBacks);
             CFDictionarySetValue(cursor_cache, cursor,
                                  cursor_name ? (CFTypeRef)cursor_name : (CFTypeRef)cursor_frames);
-            LeaveCriticalSection(&cursor_cache_section);
+            pthread_mutex_unlock(&cursor_cache_mutex);
         }
         else
             cursor_name = CFRetain(CFSTR("arrowCursor"));




More information about the wine-cvs mailing list