winemac: Use pthread for cursor cache locking.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-05-17 01:16:59 +02:00 committed by Alexandre Julliard
parent eae3578d89
commit 3ab98869bb
1 changed files with 7 additions and 15 deletions

View File

@ -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"));