dispose created fonts - they are not disposed automatically by SWT

This commit is contained in:
Anton Keks 2020-12-23 13:05:42 +02:00
parent 4e6cc3202b
commit 43c9a048f0
3 changed files with 7 additions and 7 deletions

View File

@ -1,3 +1,6 @@
Unreleased:
- Cleanup some GUI resource leaks
Changes in 3.7.3:
- Local IP address popup will now list IPv6 addresses and support IPv6 netmasks
- Support for silent uninstall on Windows #263

View File

@ -41,6 +41,7 @@ public class InfoDialog extends AbstractModalDialog {
FontData sysFontData = shell.getFont().getFontData()[0];
titleLabel.setLayoutData(formData(new FormAttachment(iconLabel), null, new FormAttachment(0), null));
titleLabel.setFont(new Font(null, sysFontData.getName(), sysFontData.getHeight() + 3, sysFontData.getStyle() | SWT.BOLD));
titleLabel.addDisposeListener(e -> titleLabel.getFont().dispose());
titleLabel.setText(title2);
Text statsText = new Text(shell, SWT.MULTI | SWT.READ_ONLY);
@ -62,16 +63,10 @@ public class InfoDialog extends AbstractModalDialog {
return super.getShellStyle() | SWT.SHEET;
}
/**
* @return Returns the message.
*/
public String getMessage() {
return message;
}
/**
* @param message The message to set.
*/
public InfoDialog setMessage(String message) {
this.message = message;
return this;

View File

@ -46,7 +46,9 @@ public class LayoutHelper {
public static Font iconFont(Shell shell) {
FontData fontData = shell.getFont().getFontData()[0];
fontData.setHeight(fontData.getHeight() * 4/3);
return new Font(shell.getDisplay(), fontData);
Font font = new Font(shell.getDisplay(), fontData);
shell.addDisposeListener(e -> font.dispose());
return font;
}
public static Image icon(final String baseName) {