diff --git a/mpicbg/src/main/java/mpicbg/models/TileUtil.java b/mpicbg/src/main/java/mpicbg/models/TileUtil.java index 103f77a..9bfc086 100644 --- a/mpicbg/src/main/java/mpicbg/models/TileUtil.java +++ b/mpicbg/src/main/java/mpicbg/models/TileUtil.java @@ -249,9 +249,13 @@ private static Void fitAndApplyWorker( final boolean canBeProcessed = Collections.disjoint(tile.getConnectedTiles(), executingTiles); if (canBeProcessed) { - tile.fitModel(); - tile.apply(damp); - executingTiles.remove(tile); + try { + tile.fitModel(); + tile.apply(damp); + } finally { + // clean up if there was an exception, otherwise this can cause a deadlock + executingTiles.remove(tile); + } } else { executingTiles.remove(tile); pendingTiles.addLast(tile);