Commit bbb5fb7e authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

uxtheme: Use atomic functions for reference counting.

parent 113eca09
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment