NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 1022 - Orphan windows when Quit was cancelled
Orphan windows when Quit was cancelled
Status: RESOLVED FIXED
Product: Fiji
Classification: Unclassified
Component: Other
unspecified
PC Windows
: P5 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2015-03-11 09:17 CDT by Jan Eglinger
Modified: 2015-04-21 11:40 CDT
3 users (show)

See Also:

Description Jan Eglinger 2015-03-11 09:17:49 CDT
When you quit Fiji while there are unsaved images, a dialog will ask whether to save changes for each modified image. After cancelling one of the dialogs, the corresponding image window remains open but is inaccessible via the Window menu, and cannot be closed by its window's close button.

To reproduce, you can use the following macro code. Run it and press Cancel in the first dialog. A blobs.gif window will remain open, but there's no blobs.gif entry in the Window menu, and you cannot close the window. Running File>Close will result in a message "There are no images open."

  run("Blobs (25K)");
  run("Invert");
  run("Blobs (25K)");
  run("Invert");
  run("Quit");
  selectWindow("blobs-1.gif");
  close();



Information about your version of Java:

  os.arch => amd64
  os.name => Windows 7
  os.version => 6.1
  java.version => 1.6.0_24
  java.vendor => Sun Microsystems Inc.
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_24-b07
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 19.1-b02
  java.vm.vendor => Sun Microsystems Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => sun.awt.Win32GraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => windows
  file.separator => \

The up-to-date check says: REMIND_LATER

Information relevant to JAVA_HOME related problems:

  JAVA_HOME is set to: C:\UTILIT~1\FIJI-D~1.APP/java/win64/jdk1.6.0_24//jre
  imagej.dir => C:\UTILIT~1\FIJI-D~1.APP

Information about the version of each plugin:

Activated update sites:
ImageJ: http://update.imagej.net/ (last check:20150309141004)
Fiji: http://fiji.sc/update/ (last check:20150310172923)
Comment 1 Mark Hiner 2015-03-11 09:32:28 CDT
Confirmed. Also happens in a fresh ImageJ 1.49p. Thanks for the great report Jan!
Comment 2 Wayne Rasband 2015-03-11 19:19:28 CDT
This bug is fixed in the latest ImageJ daily build (1.49q5). The ImageWindow.close() method displayed a "save changes?" dialog because IJ.macroRunning() returned false. It returned false because the 'quit' code in ImageJ runs on a separate thread. The daily build works around this problem by adding a quittingViaMacro() method that the close() method queries.
Comment 3 Jan Eglinger 2015-03-12 03:02:06 CDT
Hi Wayne,

sorry, this doesn't fix the bug for me:

with ImageJ v1.49q5 (in Fiji), there are now *two* orphan windows after I cancel the "save changes" dialog (an additional error appears: No window with the title "blobs-1.gif" found.).
Moreover, when I click on "No" to discard changes, ImageJ does not ask to save the changes in the second unsaved image (it did so before).

Please notice that the bug I reported is not limited to the use of the macro language, it appears when quitting via File>Quit or when closing the Fiji main window.

In summary, the changes in 1.49q5 make it even worse for me.

Jan
Comment 4 Wayne Rasband 2015-03-12 10:49:59 CDT
Hi Jan,

This seems to be a problem with the Fiji Script Editor. Your test macro works as expected with v1.49q5 if I run it in Fiji using the Plugins>Macros>Run command, or if I run it by pasting it into Fiji (where it opens in the ImageJ macro editor) or if I run it in ImageJ. I also do not see a problem if I exit Fiji by using the File>Quit command or by closing the main Fiji window. I do see the problem if I run the test macro in the Script Editor and click "Cancel" in the "Select an Option" dialog displayed by the Script Editor.
Comment 5 Jan Eglinger 2015-03-12 11:15:34 CDT
Apparently our expectations differ then :)

I just ran the test macro by copying the code and then opening it in the macro editor by File>New>System Clipboard
Running the macro like this (with ImageJ 1.49q5) results in Fiji quitting without *any* dialog. I would have expected a dialog for each image that contains unsaved changes.

Anyhow, I can confirm that the behaviour is Fiji- (or Script editor-)related now, because in plain ImageJ the macro works as you describe (although I would expect dialogs if there are unsaved changes, even when the quit command was issued from a macro).
Comment 6 Wayne Rasband 2015-03-12 12:11:23 CDT
Macro functions that close image windows (e.g., close(), run("Close"), run("Close All") and run("Quit")) do not display "save changes" dialogs. Here is a version of the test macro that displays a dialog before calling run("Quit"):

  run("Blobs (25K)");
  run("Invert");
  run("Blobs (25K)");
  run("Invert");
  n = 0;
  for (i=1; i<=nImages; i++) {
     selectImage(i);
     if (is("changes")) n++;
  }
  if (n>0) {
     msg = "There are "+n+" images with changes";
     showMessageWithCancel("Quit?", msg);
  }
  run("Quit");
  selectWindow("blobs-1.gif");
  close();
Comment 7 Mark Hiner 2015-03-13 09:02:12 CDT
 Jan - the original cause for bug report is that ImageWindows do not get disposed when they are closed during a potential quit operation[1].

 Fiji makes some significant changes to what ImageJ does when it quits, which Curtis discussed in a news post[2].

 So on the Fiji side we have to take some extra precautions when images are closed to ensure they are disposed, so things don't get out of synch in the event of a subsequent cancel[3, 4].

 Note that these patches won't affect the ImageJ 1.49q5 behavior when closing from a macro. That is a separate issue[5], but something we should be able to easily accommodate when we upgrade to 1.49q.

Thanks again!

[1] https://github.com/imagej/ImageJA/blob/v1.49p/src/main/java/ij/gui/ImageWindow.java#L401-403

[2] http://imagej.net/2014-07-11_-_Fiji_won%27t_quit!

[3] https://github.com/imagej/ij1-patcher/commit/1eef7e2e7b3b41df66ba90a09849e793ef180eb4

[4] https://github.com/imagej/imagej-legacy/commit/5b7185b228feedf69c516f31124cfe0e6f17d709

[5] https://github.com/imagej/ij1-patcher/issues/34
Comment 8 Curtis Rueden 2015-04-21 11:40:28 CDT
Presumed fixed. Please reopen if not.