This follows the same lines, in some cases MSSTYLES_SetActiveTheme would return success when in fact it failed Apply on top of Vitaliy's patch
Changelog: Ensure MSSTYLES_SetActiveTheme fails when theme fails to load
...
invalid_theme: if(hTheme) FreeLibrary(hTheme);
- if(!hr) hr = HRESULT_FROM_WIN32(GetLastError());
- if(SUCCEEDED(hr)) hr = HRESULT_FROM_WIN32(GetLastError());
- if(SUCCEEDED(hr)) hr = E_FAIL; return hr;
You shouldn't be doing this in the first place. As you have seen, at best you will set hr to a random error and at worst it won't be set at all and you need your hack to make it still work. What you should be doing is setting hr to the correct error as soon as you detect a failure. So after a Win32 call: if (callfailed) { hr = HRESULT_FROM_WIN32(GetLastError()); goto invalid_theme; }
or after another type of failure:
if (somethingnotquiteright) { hr = E_FAIL; goto invalid_theme; }
Also, please try to use a more descriptive code than E_FAIL if one exists.
Rob