Skip to content

Commit 7b2f0dc

Browse files
committed
[Win32] Properly handle setting null font to GC #2350
When calling GC#setFont(), a copy of the given font is created. However, the font may be null, leading to an exception. In addition, a font should be retrieved from the font provider instead of creating a new font that is manually disposed later on. This change ensures that null fonts are properly handled and that the stored font is retrieved from the provider. Fixes #2350
1 parent a68fd8d commit 7b2f0dc

File tree

1 file changed

+1
-2
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+1
-2
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5015,8 +5015,7 @@ private class SetFontOperation extends Operation {
50155015
private final Font font;
50165016

50175017
SetFontOperation(Font font) {
5018-
this.font = new Font(font.getDevice(), font.getFontData());
5019-
registerForDisposal(this.font);
5018+
this.font = font != null ? SWTFontProvider.getFont(font.getDevice(), font.getFontData()[0], data.nativeZoom) : null;
50205019
}
50215020

50225021
@Override

0 commit comments

Comments
 (0)