-
Notifications
You must be signed in to change notification settings - Fork 187
[Win32] Do not set IME font if the font is disposed #2365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Win32] Do not set IME font if the font is disposed #2365
Conversation
ShahzaibIbrahim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look sound and adhere to previous state. I have just one comment.
| { | ||
| hFont = font.isDisposed() ? 0 : SWTFontProvider.getFontHandle(font, getNativeZoom()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check for font being disposed inside of the SWTFontProvider.getFontHandle and return 0 if its disposed? Wouldn't that be safer for all the consumers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yes, sounds good to me. That would solve this issue here as well and is equal to the original behavior: Is a font disposed return a 0 handle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
053451d to
0ddbf9f
Compare
ShahzaibIbrahim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Approved
…2323 Prior to recent changes that ensure that a font handle is always retrieved via the SWTFontProvider, the hFont variable in Caret::setIMEFont was retrieved directly from the font object (using font.handle). Since those recent changes, hFont is fetched via SWTFontProvider, which throws an exception if the font is disposed. Previously, when the font was disposed, hFont (font.handle) would be zero, and the method would fall back to using defaultFont for setting the IME font. Now, this fallback no longer works because the exception is thrown before the fallback can occur. This commit restores the intended behavior by setting hFont as zero if the font is disposed, preventing the exception. Fixes eclipse-platform#2323
0ddbf9f to
1426edf
Compare
HeikoKlare
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is sound and fixes the reported issue.
I have adapted the PR with corrected formatting and slightly updated the commit message to fit to our recommendations.
Prior to PR #2062, the
hFontvariable inCaret::setIMEFontwas retrieved directly from thefontobject (usingfont.handle). Since #2602,hFontis fetched viaSWTFontProvider, which throws an exception if the font is disposed.Previously, when the font was disposed, hFont (
font.handle) would be zero, and the method would fall back to using defaultFont for setting the IME font. After #2602, this fallback no longer works because the exception is thrown before the fallback can occur.This commit restores the intended behavior by setting
hfontas zero if the font is disposed, preventing the exception.Fixes #2323
Steps to reproduce
Run the snippet provided in #2323 (comment).
Without this change, an exception will be thrown when the font is disposed.