user32: Convert the icon cache to a standard Wine list.

This commit is contained in:
Alexandre Julliard 2010-10-08 15:06:16 +02:00
parent 990842a322
commit 975bff627b
1 changed files with 8 additions and 14 deletions

View File

@ -38,6 +38,7 @@
#include "wine/server.h" #include "wine/server.h"
#include "controls.h" #include "controls.h"
#include "user_private.h" #include "user_private.h"
#include "wine/list.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(cursor); WINE_DEFAULT_DEBUG_CHANNEL(cursor);
@ -76,15 +77,10 @@ static const WCHAR DISPLAYW[] = {'D','I','S','P','L','A','Y',0};
/********************************************************************** /**********************************************************************
* ICONCACHE for cursors/icons loaded with LR_SHARED. * ICONCACHE for cursors/icons loaded with LR_SHARED.
*
* FIXME: This should not be allocated on the system heap, but on a
* subsystem-global heap (i.e. one for all Win16 processes,
* and one for each Win32 process).
*/ */
typedef struct tagICONCACHE typedef struct tagICONCACHE
{ {
struct tagICONCACHE *next; struct list entry;
HMODULE hModule; HMODULE hModule;
HRSRC hRsrc; HRSRC hRsrc;
HRSRC hGroupRsrc; HRSRC hGroupRsrc;
@ -94,7 +90,7 @@ typedef struct tagICONCACHE
} ICONCACHE; } ICONCACHE;
static ICONCACHE *IconAnchor = NULL; static struct list icon_cache = LIST_INIT( icon_cache );
static CRITICAL_SECTION IconCrst; static CRITICAL_SECTION IconCrst;
static CRITICAL_SECTION_DEBUG critsect_debug = static CRITICAL_SECTION_DEBUG critsect_debug =
@ -413,7 +409,7 @@ static HICON CURSORICON_FindSharedIcon( HMODULE hModule, HRSRC hRsrc )
EnterCriticalSection( &IconCrst ); EnterCriticalSection( &IconCrst );
for ( ptr = IconAnchor; ptr; ptr = ptr->next ) LIST_FOR_EACH_ENTRY( ptr, &icon_cache, ICONCACHE, entry )
if ( ptr->hModule == hModule && ptr->hRsrc == hRsrc ) if ( ptr->hModule == hModule && ptr->hRsrc == hRsrc )
{ {
ptr->count++; ptr->count++;
@ -443,16 +439,15 @@ static ICONCACHE* CURSORICON_FindCache(HICON hIcon)
{ {
ICONCACHE *ptr; ICONCACHE *ptr;
ICONCACHE *pRet=NULL; ICONCACHE *pRet=NULL;
BOOL IsFound = FALSE;
EnterCriticalSection( &IconCrst ); EnterCriticalSection( &IconCrst );
for (ptr = IconAnchor; ptr != NULL && !IsFound; ptr = ptr->next) LIST_FOR_EACH_ENTRY( ptr, &icon_cache, ICONCACHE, entry )
{ {
if ( hIcon == ptr->hIcon ) if ( hIcon == ptr->hIcon )
{ {
IsFound = TRUE;
pRet = ptr; pRet = ptr;
break;
} }
} }
@ -476,8 +471,7 @@ static void CURSORICON_AddSharedIcon( HMODULE hModule, HRSRC hRsrc, HRSRC hGroup
ptr->count = 1; ptr->count = 1;
EnterCriticalSection( &IconCrst ); EnterCriticalSection( &IconCrst );
ptr->next = IconAnchor; list_add_head( &icon_cache, &ptr->entry );
IconAnchor = ptr;
LeaveCriticalSection( &IconCrst ); LeaveCriticalSection( &IconCrst );
} }
@ -491,7 +485,7 @@ static INT CURSORICON_DelSharedIcon( HICON hIcon )
EnterCriticalSection( &IconCrst ); EnterCriticalSection( &IconCrst );
for ( ptr = IconAnchor; ptr; ptr = ptr->next ) LIST_FOR_EACH_ENTRY( ptr, &icon_cache, ICONCACHE, entry )
if ( ptr->hIcon == hIcon ) if ( ptr->hIcon == hIcon )
{ {
if ( ptr->count > 0 ) ptr->count--; if ( ptr->count > 0 ) ptr->count--;