1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 03:45:57 +00:00

uxtheme: Use atomic functions for reference counting.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
This commit is contained in:
Zhiyi Zhang 2022-08-12 11:32:54 +08:00 committed by Alexandre Julliard
parent 113eca095a
commit bbb5fb7e25
2 changed files with 9 additions and 6 deletions

View File

@ -171,7 +171,7 @@ HRESULT MSSTYLES_OpenThemeFile(LPCWSTR lpThemeFile, LPCWSTR pszColorName, LPCWST
(*tf)->pszAvailSizes = pszSizes;
(*tf)->pszSelectedColor = pszSelectedColor;
(*tf)->pszSelectedSize = pszSelectedSize;
(*tf)->dwRefCount = 1;
(*tf)->refcount = 1;
return S_OK;
invalid_theme:
@ -187,9 +187,12 @@ invalid_theme:
*/
void MSSTYLES_CloseThemeFile(PTHEME_FILE tf)
{
LONG refcount;
if(tf) {
tf->dwRefCount--;
if(!tf->dwRefCount) {
refcount = InterlockedDecrement(&tf->refcount);
if (!refcount)
{
if(tf->hTheme) FreeLibrary(tf->hTheme);
if(tf->classes) {
while(tf->classes) {
@ -235,7 +238,7 @@ HRESULT MSSTYLES_SetActiveTheme(PTHEME_FILE tf, BOOL setMetrics)
tfActiveTheme = tf;
if (tfActiveTheme)
{
tfActiveTheme->dwRefCount++;
InterlockedIncrement(&tfActiveTheme->refcount);
if(!tfActiveTheme->classes)
MSSTYLES_ParseThemeIni(tfActiveTheme, setMetrics);
}
@ -1061,7 +1064,7 @@ PTHEME_CLASS MSSTYLES_OpenThemeClass(LPCWSTR pszAppName, LPCWSTR pszClassList, U
if(cls) {
TRACE("Opened app %s, class %s from list %s\n", debugstr_w(cls->szAppName), debugstr_w(cls->szClassName), debugstr_w(pszClassList));
cls->tf = tfActiveTheme;
cls->tf->dwRefCount++;
InterlockedIncrement(&cls->tf->refcount);
InterlockedIncrement(&cls->refcount);
cls->dpi = dpi;
}

View File

@ -71,7 +71,7 @@ typedef struct _THEME_IMAGE {
} THEME_IMAGE, *PTHEME_IMAGE;
typedef struct _THEME_FILE {
DWORD dwRefCount;
LONG refcount;
HMODULE hTheme;
WCHAR szThemeFile[MAX_PATH];
LPWSTR pszAvailColors;