Skip to content

Commit

Permalink
DefaultLegacyHooks: also skip closed ImageWindows
Browse files Browse the repository at this point in the history
When ImageJ1 is quitting, the WindowManager.closeAllWindows() method
marks each ImageWindow as closed, but does not actually hide it. So the
ImageJ2 heuristic of checking whether the window is still visible after
it receives a windowClosing event fails. The workaround is to check, in
the case of ImageWindows, whether their isClosed() method returns true,
and if so, continue.

This change results in ImageJ1 shutting down successfully again when
image windows are still open.
  • Loading branch information
ctrueden committed Jul 9, 2014
1 parent 57a4cca commit 62259da
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/net/imagej/legacy/DefaultLegacyHooks.java
Expand Up @@ -32,6 +32,7 @@
package net.imagej.legacy;

import ij.ImagePlus;
import ij.gui.ImageWindow;

import java.awt.Window;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -560,7 +561,13 @@ public boolean disposing() {
// -- Helper methods --

private boolean isOpenWindow(final Window window) {
return window.isVisible();
return window.isVisible() && !isClosedImageWindow(window);
}

private boolean isClosedImageWindow(final Window window) {
if (!(window instanceof ImageWindow)) return false;
final ImageWindow imageWindow = (ImageWindow) window;
return imageWindow.isClosed();
}

}

0 comments on commit 62259da

Please sign in to comment.