uxtheme Prevent segfault if no theme is set

Kevin Koltzau kevin at plop.org
Sun Jan 25 10:42:58 CST 2004


More appropriate fix (I guess I was feeling a bit lazy with that last patch)

Changelog:
    Ensure MSSTYLES_SetActiveTheme fails properly when theme is invalid


On Sunday 25 January 2004 06:18 am, Robert Shearman wrote:
> > 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openthemefile2.diff
Type: text/x-diff
Size: 1979 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20040125/57ffc721/openthemefile2.bin


More information about the wine-patches mailing list