From ce088da19fb8bd27b1edbe78b247f48afcaa3003 Mon Sep 17 00:00:00 2001 From: Anton Keks Date: Wed, 23 Dec 2020 13:12:59 +0200 Subject: [PATCH] cache created dialog icon to avoid creating and leaking them --- src/net/azib/ipscan/gui/AbstractModalDialog.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/net/azib/ipscan/gui/AbstractModalDialog.java b/src/net/azib/ipscan/gui/AbstractModalDialog.java index 46ff44f3..2477718d 100644 --- a/src/net/azib/ipscan/gui/AbstractModalDialog.java +++ b/src/net/azib/ipscan/gui/AbstractModalDialog.java @@ -21,8 +21,8 @@ import org.eclipse.swt.widgets.*; * @author Anton Keks */ public abstract class AbstractModalDialog { - protected Shell shell; + private static Image icon; public void open() { if (shell == null || shell.isDisposed()) { @@ -66,13 +66,8 @@ public abstract class AbstractModalDialog { } shell = new Shell(parent, getShellStyle()); - Image icon = null; - if (parent != null) { - icon = parent.getImage(); - } - if (icon == null) { - icon = new Image(shell.getDisplay(), getClass().getResourceAsStream("/images/icon.png")); - } + if (icon == null && parent != null) icon = parent.getImage(); + if (icon == null) icon = new Image(shell.getDisplay(), getClass().getResourceAsStream("/images/icon.png")); shell.setImage(icon); populateShell(); @@ -88,7 +83,6 @@ public abstract class AbstractModalDialog { /** * Positions 2 buttons at the bottom-right part of the shell. * On MacOS also changes OK and cancel button order. - * @param okButton * @param cancelButton can be null */ protected void positionButtons(Button okButton, Button cancelButton) { @@ -121,8 +115,6 @@ public abstract class AbstractModalDialog { /** * Positions 2 buttons at the bottom-right part of the shell in the FormLayout. * On MacOS also changes OK and cancel button order. - * @param okButton - * @param cancelButton * @param control the bottom-right widget, used as a guide */ protected void positionButtonsInFormLayout(Button okButton, Button cancelButton, Control control) {