Skip to content

Commit e285a01

Browse files
committed
TiledDataViewer: avoid NPE and handle missing data
when zomming in or out gracefully.
1 parent 5e06b92 commit e285a01

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • libraries/TiledDataViewer/src/main/java/org/micromanager/tileddataviewer/internal/gui

libraries/TiledDataViewer/src/main/java/org/micromanager/tileddataviewer/internal/gui/ImageMaker.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ public synchronized Image makeOrGetImage(DataViewCoords viewCoords) {
210210
TaggedImage imageForDisplay = getDisplayImage(axes, viewCoords.getResolutionIndex(),
211211
viewOffsetAtResX, viewOffsetAtResY, imagePixelWidth, imagePixelHeight);
212212

213+
// The requested resolution level / region may have no data yet - e.g. a zoom
214+
// that requests a pyramid level still being generated while tiles are acquired
215+
// concurrently. Skip this channel for now (keeping the last frame for it); the
216+
// next render fills it in once the data is ready. Without this guard the null
217+
// deref below throws, aborts the render, and leaves the canvas blank until the
218+
// zoom level changes.
219+
if (imageForDisplay == null) {
220+
continue;
221+
}
222+
213223
if (latestTags_ == null
214224
|| (viewCoords.getAxesPositions().containsKey(TiledDataViewer.CHANNEL_AXIS)
215225
&& viewCoords.getAxesPositions().get(TiledDataViewer.CHANNEL_AXIS)

0 commit comments

Comments
 (0)