Skip to content

Commit 120e1b8

Browse files
committed
Fix Headless exceptions
1 parent be32fed commit 120e1b8

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

‎src/main/java/sc/fiji/snt/SNT.java‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,7 @@ private void nullifyCanvases(final boolean disposeXY) {
633633
}
634634

635635
public boolean accessToValidImageData() {
636-
// NB: Currently we are assuming that image data comes from an ImagePlus. This
637-
// needs to be changed when ImagePlus requirements are lift. Note that xy may
638-
// be null (e.g., image has been manually closed), but its cached data ctSlice3d
639-
// may still be available. Return ctSlice3d != null is problematic on its own,
640-
// because there are several calls to this method that happen _before_ ctSlice3d
641-
// has been assembled, but _after_ an image has been specified
642-
return getImagePlus() != null && !isDisplayCanvas(xy);
636+
return (getImagePlus() != null && !isDisplayCanvas(xy)) || ctSlice3d != null;
643637
}
644638

645639
private void setIsDisplayCanvas(final ImagePlus imp) {
@@ -839,7 +833,7 @@ public void rebuildZYXZpanes() {
839833
if (!xz.isVisible()) xz.show();
840834
}
841835

842-
@SuppressWarnings("unchecked")
836+
@SuppressWarnings("unchecked")
843837
private void loadDatasetFromImagePlus(final ImagePlus imp) {
844838
statusService.showStatus("Loading data...");
845839
this.ctSlice3d = ImgUtils.getCtSlice3d(imp, channel - 1, frame - 1);

‎src/main/java/sc/fiji/snt/hyperpanes/MultiDThreePanes.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
package sc.fiji.snt.hyperpanes;
2424

25-
import java.awt.Color;
25+
import java.awt.*;
2626
import java.awt.image.ColorModel;
2727

2828
import ij.ImagePlus;
@@ -664,6 +664,7 @@ private void initialize(final int frame) {
664664
}
665665

666666
private void initCanvasesAndWindows() {
667+
if (GraphicsEnvironment.isHeadless()) return;
667668
xy_canvas = createCanvas(xy, XY_PLANE);
668669
if (isDummy()) {
669670
xy_window = null;

0 commit comments

Comments
 (0)