From c742c14a52ddc30521b1dd77e63564c03ad3b574 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 17 Jan 2013 16:24:15 +0100 Subject: [PATCH] Safeguard against listeners that recreate the grid We need to handle the backbuffer before we fire the loadend event. Otherwise listeners that call e.g. mergeNewParams() will cause the backbuffer removal code to fail, because tile.imgDiv (and hence this._transitionElement) will be null. --- lib/OpenLayers/Layer/Grid.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 96a5f8f394..6989594fa3 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -1104,8 +1104,6 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { } //if that was the last tile, then trigger a 'loadend' on the layer if (this.numLoadingTiles === 0) { - this.loading = false; - this.events.triggerEvent("loadend"); if(this.backBuffer) { this._transitionElement = tile.imgDiv; for (var i=this.transitionendEvents.length-1; i>=0; --i) { @@ -1119,6 +1117,8 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { this._removeBackBuffer, this.removeBackBufferDelay ); } + this.loading = false; + this.events.triggerEvent("loadend"); } };