- ok( bTPDefined == FALSE, "Expected FALSE\n" );
- ok( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got 0x%08lx\n", GetLastError() );
I am not sure of the exact intent of the original commit d9c5cef339c7e169e6b9dbd96a3158f91fa9056c. But it seems to me here IsThemePartDefined() is deliberately tested after the theme handle is closed. Similar to the GetWindowTheme(). So I would prefer not to move this.
There are several hTheme leaks, so I'd guess that it's pure luck that the IsThemePartDefined() test succeded. It looks like the author of the commit didn't notice that the result of the test depends on a side effect. I'd expect to see a comment with an explanation why the test is placed after the CloseThemeData() call. If you insist I'll leave this test alone, and not fix hTheme leaks at all, however it's not guaranteed that somebody else (Coverity?) will notice the leaks, and will try to fix them later.