From a9bbb01d76660e172af71a6dcecfc05fcaf61781 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Fri, 22 Nov 2024 16:06:37 -0500 Subject: [PATCH] Guard against switching on and off overlay layers quickly If an overlay annotation was requested and then dismissed before obtaining data about it, a javascript error would be raised. This didn't cause an issue, but should be cleaned up properly. --- CHANGELOG.md | 1 + .../girder_large_image_annotation/rest/annotation.py | 2 +- .../web_client/views/imageViewerWidget/geojs.js | 10 +++++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dcfd0503..01d13b227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Fix an issue searching for annotation metadata on items that a user doesn't have permissions to view ([#1723](../../pull/1723)) - Fix a typo in a column header ([#1727](../../pull/1727)) +- Guard against switching on and off overlay layers quickly ([#1729](../../pull/1729)) ## 1.30.2 diff --git a/girder_annotation/girder_large_image_annotation/rest/annotation.py b/girder_annotation/girder_large_image_annotation/rest/annotation.py index feaa7886b..400326386 100644 --- a/girder_annotation/girder_large_image_annotation/rest/annotation.py +++ b/girder_annotation/girder_large_image_annotation/rest/annotation.py @@ -255,7 +255,7 @@ def generateResult(): # could be used in its most default mode instead like so: # result = json.dumps(element, separators=(',', ':')) # Collect multiple elements before emitting them. This - # balances using less memoryand streaming right away with + # balances using less memory and streaming right away with # efficiency in dumping the json. Experimentally, 100 is # significantly faster than 10 and not much slower than 1000. collect.append(element) diff --git a/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js b/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js index 9fb9f0589..083bfeea4 100644 --- a/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js +++ b/girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js @@ -415,9 +415,13 @@ var GeojsImageViewerWidgetExtension = function (viewer) { restRequest({ url: `item/${overlayItemId}/tiles` }).done((response) => { - // Since overlay layers are created asynchronously, we need to ensure that an attempt - // to draw the same overlays happening at roughly the same time does not create - // extra layers + // Since overlay layers are created asynchronously, we need + // to ensure that an attempt to draw the same overlays + // happening at roughly the same time does not create extra + // layers + if (!this.viewer) { + return; + } const conflictingLayers = this.viewer.layers().filter( (layer) => layer.id() === overlay.id); if (conflictingLayers.length > 0) {