Add slice to stack throws exception

imagej

#1

This is the second time this week that my running instance of Fiji cannot add a slice to a single slice image. The exception reads:

(Fiji Is Just) ImageJ 2.0.0-rc-39/1.50a; Java 1.8.0_45-internal [64-bit]; Linux 3.19.0-28-generic; 19251MB of 89623MB (21%)

java.lang.IllegalArgumentException: adding a container to a container on a different GraphicsDevice
at java.awt.Component.checkGD(Component.java:1185)
at java.awt.Container.addImpl(Container.java:1091)
at java.awt.Container.add(Container.java:415)
at ij.gui.ImageWindow.add(ImageWindow.java:515)
at ij.gui.ImageWindow.<init>(ImageWindow.java:87)
at ij.gui.StackWindow.<init>(StackWindow.java:28)
at ij.ImagePlus.setStack(ImagePlus.java:669)
at ij.plugin.StackEditor.addSlice(StackEditor.java:51)
at ij.plugin.StackEditor.run(StackEditor.java:23)
at ij.IJ.runPlugIn(IJ.java:182)
at ij.Executer.runCommand(Executer.java:132)
at ij.Executer.run(Executer.java:65)
at java.lang.Thread.run(Thread.java:745)

The symptom is that the window does not get a a slider to browse through the sections. Surprisingly, when I duplicate the window, it offers to copy itself as a stack with as many slices as I’ve attempted to add. The duplicate window does have the slider and several slices. Obviously some UI hickup for which duplicate and delete is a life saving workaround, but confusing anyways.


#2

Looks like a known-and-still-open bug in Java:

The description says the bug “happens when you add a Component to a Container on another graphics device, without explicitly removing the Component from its previous parent.” So it might be possible to work around it in the ImageJ1 code.