From c4aa3715a70e28d5c681fcdcd7496aaa95da7b48 Mon Sep 17 00:00:00 2001 From: Grant Echols Date: Wed, 23 Sep 2015 15:19:02 -0600 Subject: [PATCH] Fixed problem with missing .length in for loop of raiseAddItemFailed event. Added viewer._cancelPendingImages method that clears the loadQueue. Added call to _cancelPendingImages from within the world.removeAll method. --- src/viewer.js | 9 ++++++++- src/world.js | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/viewer.js b/src/viewer.js index bca49e5c..215f14f8 100644 --- a/src/viewer.js +++ b/src/viewer.js @@ -1243,7 +1243,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, }; function raiseAddItemFailed( event ) { - for (var i = 0; i < _this._loadQueue; i++) { + for (var i = 0; i < _this._loadQueue.length; i++) { if (_this._loadQueue[i] === myQueueItem) { _this._loadQueue.splice(i, 1); break; @@ -1982,6 +1982,13 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype, for ( i = 0; i < length; i++ ) { this.currentOverlays[ i ].drawHTML( this.overlaysContainer, this.viewport ); } + }, + + /** + * Cancel the "in flight" images. + */ + _cancelPendingImages: function() { + this._loadQueue = []; } }); diff --git a/src/world.js b/src/world.js index 277a6068..0c0502aa 100644 --- a/src/world.js +++ b/src/world.js @@ -202,6 +202,8 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W * @fires OpenSeadragon.World.event:metrics-change */ removeAll: function() { + // We need to make sure any pending images are canceled so the world items don't get messed up + this.viewer._cancelPendingImages(); var item; for (var i = 0; i < this._items.length; i++) { item = this._items[i];