Skip to content

Make FontData key in map immutable #1994

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

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -72,7 +72,8 @@ public Font getFont(FontData fontData, int zoom) {
}

private Font registerFont(FontData fontData, Font font) {
fontsMap.put(fontData, font);
FontData clonedFontData = new FontData(fontData.toString());
fontsMap.put(clonedFontData, font);
return font;
}

Original file line number Diff line number Diff line change
@@ -130,8 +130,9 @@ public Font getFont(FontData fontData, int zoom) {
if (customFontsKeyMap.containsKey(fontData)) {
container = customFontsKeyMap.get(fontData);
} else {
container = new ScaledCustomFontContainer(fontData);
customFontsKeyMap.put(fontData, container);
FontData clonedFontData = new FontData(fontData.toString());
container = new ScaledCustomFontContainer(clonedFontData);
customFontsKeyMap.put(clonedFontData, container);
}
return container.getScaledFont(zoom);
}
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ public void test_ConstructorLjava_lang_String() {
FontData fd = new FontData(SwtTestUtil.testFontName, 10, SWT.NORMAL);
FontData reconstructedFontData = new FontData(fd.toString());
assertEquals(fd, reconstructedFontData);
assertEquals(fd.hashCode(), reconstructedFontData.hashCode());
}

@Test