imagej/imagej2

Overlay Elements' Save as... raises exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

rgaiacs opened this issue · 3 comments

I'm trying to save the measurements from overlay elements as CSV and ImageJ is raising a exception.

Minimum Steps to Reproduce

As ImageJ macro:

run("Particles");
run("Invert");
run("Analyze Particles...", "  show=Overlay exclude clear include");
run("List Elements");

From Overlay Elements window, File > Save as.... Click Save on the dialog window.

Observed Result/Output

ImageJ recover from exception. No file is save.

Exception in thread "Run$_AWT-EventQueue-0" java.lang.NullPointerException
	at ij.measure.ResultsTable.getRowAsString(ResultsTable.java:615)
	at ij.measure.ResultsTable.saveAs(ResultsTable.java:1260)
	at ij.measure.ResultsTable.save(ResultsTable.java:1219)
	at ij.measure.ResultsTable.saveAndRename(ResultsTable.java:1231)
	at ij.text.TextPanel.saveAs(TextPanel.java:907)
	at ij.text.TextPanel.doCommand(TextPanel.java:468)
	at ij.text.TextWindow.actionPerformed(TextWindow.java:264)
	at java.awt.MenuItem.processActionEvent(MenuItem.java:669)
	at java.awt.MenuItem.processEvent(MenuItem.java:628)
	at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351)
	at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
	at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:354)
	at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:761)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Expected Result/Output

CSV file is save.

Environment

$ ./ImageJ-linux64 --headless --help 2>&1 | head -n 3 | tail -n 1
ImageJ launcher 4.0.5 (build 1260)

I can reproduce with an up-to-date Fiji, as well as with the latest build of ij.jar.

The variable value seems to be null here:

https://github.com/imagej/imagej1/blob/dd51b56852398a6dcea6543718913bfa732bf877/ij/measure/ResultsTable.java#L646

@rasband any idea?

This bug is fixed in the ImageJ 1.53h29 daily build. Here is a macro that reproduces the problem:

  run("Fresh Start");
  run("Particles");
  run("Invert");
  run("Analyze Particles...", "  show=Overlay exclude clear include");
  run("List Elements");
  Table.save(getDir("downloads")+"test.csv");