On Mon, 22 Apr 2024 07:00:52 GMT, Tejesh R <t...@openjdk.org> wrote: >> I agree. The current approach calls `openThemeImpl` three times: once or >> twice with the passed `dpi` and then once with `defaultDPI` as the fallback. >> Moreover, it *leaks theme handles* if `openThemeImpl` returns non-zero value >> and it does so repeatedly even when there's a cached theme handle. >> >> Handling the failure inside `openThemeImpl` seems a better option. Even >> though it results in a higher memory usage. >> >> I believe `openTheme` returns 0 because the DPI of a printer is higher than >> that of screens, and Windows doesn't support such DPIs. The problem is >> likely reproducible when you print other components such as buttons. > > Yes, `openTheme()` actually returns 0. Hence I used `null` && `0` checker.
Moved the failure handling to `openThemeImpl()`. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/18706#discussion_r1574227636