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.
This commit is contained in:
ahocevar
2013-01-17 16:24:15 +01:00
parent 0f9010cfb8
commit c742c14a52

View File

@@ -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");
}
};