diff --git a/src/net/azib/ipscan/gui/AbstractModalDialog.java b/src/net/azib/ipscan/gui/AbstractModalDialog.java index 592642d5..46bba7f3 100755 --- a/src/net/azib/ipscan/gui/AbstractModalDialog.java +++ b/src/net/azib/ipscan/gui/AbstractModalDialog.java @@ -46,13 +46,12 @@ public abstract class AbstractModalDialog { // create a separate event loop Display display = Display.getCurrent(); - while (!shell.isDisposed()) { + while (shell != null && !shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } - - // destroy the window - shell.dispose(); + // forget the reference to the shell (this class is reused in the container) + shell = null; } /** diff --git a/src/net/azib/ipscan/gui/StatisticsDialog.java b/src/net/azib/ipscan/gui/StatisticsDialog.java index 8113f07e..3645bc15 100644 --- a/src/net/azib/ipscan/gui/StatisticsDialog.java +++ b/src/net/azib/ipscan/gui/StatisticsDialog.java @@ -54,6 +54,12 @@ public class StatisticsDialog extends AbstractModalDialog { * This method initializes shell */ private void createShell() { + if (shell != null) { + // close the same window if it is already open ('scanning incomplete') + shell.close(); + shell.dispose(); + } + Display currentDisplay = Display.getCurrent(); Shell parent = currentDisplay.getShells()[0]; shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.DIALOG_TRIM);