Skip to content

Commit 599383d

Browse files
committed
Ensure font is fetched from registry even when zoom levels match
The font returned by Font.win32_new is stored in the setFont() method of widgets. Previously, if targetZoom == font.zoom, the passed font was returned directly. However, the passed font could have been disposed by user code. This change ensures that the font is always fetched from the font registry, even when the zoom levels match, avoiding potential use of disposed fonts.
1 parent 34a4d76 commit 599383d

File tree

1 file changed

+6
-3
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ public Font(Device device, String name, int height, int style) {
189189
init();
190190
}
191191

192+
@Override
193+
void init() {
194+
this.handle = SWTFontProvider.getFontHandle(this, this.zoom);
195+
super.init();
196+
}
197+
192198
@Override
193199
void destroy() {
194200
OS.DeleteObject(handle);
@@ -402,9 +408,6 @@ public static Font win32_new(Device device, FontData fontData, int zoom) {
402408
* @since 3.126
403409
*/
404410
public static Font win32_new(Font font, int targetZoom) {
405-
if (targetZoom == font.zoom) {
406-
return font;
407-
}
408411
return SWTFontProvider.getFont(font.getDevice(), font.getFontData()[0], targetZoom);
409412
}
410413
}

0 commit comments

Comments
 (0)