Skip to content

Commit 03a983c

Browse files
committed
Workaround occasional exception when quitting SNT w/ composite images
1 parent 9923f7d commit 03a983c

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,14 +3825,21 @@ private void rebuildWindow(final ImagePlus imp) {
38253825
// hiding the image will force the rebuild of its ImageWindow next time show() is
38263826
// called. We need to remove any PointRoi to bypass the "Save changes?" dialog.
38273827
// If spine/varicosity counts exist, set the images has changed to avoid data loss
3828-
final Roi roi = imp.getRoi();
3829-
final boolean existingChanges = imp.changes;
3830-
imp.changes = false;
3831-
imp.deleteRoi();
3832-
imp.hide();
3833-
imp.setRoi(roi);
3834-
imp.show();
3835-
imp.changes = existingChanges || roi instanceof PointRoi;
3828+
try {
3829+
final Roi roi = imp.getRoi();
3830+
final boolean existingChanges = imp.changes;
3831+
imp.changes = false;
3832+
imp.deleteRoi();
3833+
imp.hide();
3834+
imp.setRoi(roi);
3835+
imp.show();
3836+
imp.changes = existingChanges || roi instanceof PointRoi;
3837+
} catch (final Exception ignored) {
3838+
// we use this method to return the image back to IJ when the program is closed
3839+
// but the image was left open. ImagePlus may be partially disposed during
3840+
// shutdown (e.g., CompositeImage with null LUTs). Not much we can do here other
3841+
// than let the exit proceed.
3842+
}
38363843
}
38373844

38383845

0 commit comments

Comments
 (0)