Index: reactos/dll/win32/shell32/iconcache.cpp =================================================================== --- reactos/dll/win32/shell32/iconcache.cpp (revision 73640) +++ reactos/dll/win32/shell32/iconcache.cpp (working copy) @@ -490,6 +490,7 @@ INT bpp; DWORD ilMask; BOOL result = FALSE; + HDPA priv_sic_hdpa; TRACE("Entered SIC_Initialize\n"); @@ -499,9 +500,18 @@ return TRUE; } - sic_hdpa = DPA_Create(16); - if (!sic_hdpa) + EnterCriticalSection(&SHELL32_SicCS); + if (sic_hdpa) { + TRACE("Icon cache already initialized (another thread got it)\n"); + LeaveCriticalSection(&SHELL32_SicCS); + return TRUE; + } + + priv_sic_hdpa = DPA_Create(16); + if (!priv_sic_hdpa) + { + LeaveCriticalSection(&SHELL32_SicCS); return FALSE; } @@ -556,7 +566,7 @@ ERR("Failed to create the big icon list.\n"); goto end; } - + /* Load the document icon, which is used as the default if an icon isn't found. */ hSm = (HICON)LoadImageW(shell32_hInstance, MAKEINTRESOURCEW(IDI_SHELL_DOCUMENT), @@ -592,10 +602,10 @@ ERR("Failed to add IDI_SHELL_DOCUMENT icon to cache.\n"); goto end; } - + /* Everything went fine */ result = TRUE; - + end: /* The image list keeps a copy of the icons, we must destroy them */ if(hSm) DestroyIcon(hSm); @@ -604,14 +614,17 @@ /* Clean everything if something went wrong */ if(!result) { - if(sic_hdpa) DPA_Destroy(sic_hdpa); + if(priv_sic_hdpa) DPA_Destroy(priv_sic_hdpa); if(ShellSmallIconList) ImageList_Destroy(ShellSmallIconList); if(ShellBigIconList) ImageList_Destroy(ShellSmallIconList); - sic_hdpa = NULL; + priv_sic_hdpa = NULL; ShellSmallIconList = NULL; ShellBigIconList = NULL; } + sic_hdpa = priv_sic_hdpa; + LeaveCriticalSection(&SHELL32_SicCS); + TRACE("hIconSmall=%p hIconBig=%p\n",ShellSmallIconList, ShellBigIconList); return result;