Merge pull request #6939 from ahocevar/cachesize-fix-abort

Abort loading when tile is disposed
This commit is contained in:
Andreas Hocevar
2017-06-20 09:35:14 +02:00
committed by GitHub
2 changed files with 21 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction) {
/**
* @private
* @type {Image}
* @type {Image|HTMLCanvasElement}
*/
this.image_ = new Image();
if (crossOrigin !== null) {
@@ -60,6 +60,7 @@ ol.inherits(ol.ImageTile, ol.Tile);
ol.ImageTile.prototype.disposeInternal = function() {
if (this.state == ol.TileState.LOADING) {
this.unlistenImage_();
this.image_.src = ol.ImageTile.blankImage.toDataURL('image/png');
}
if (this.interimTile) {
this.interimTile.dispose();
@@ -95,8 +96,8 @@ ol.ImageTile.prototype.getKey = function() {
*/
ol.ImageTile.prototype.handleImageError_ = function() {
this.state = ol.TileState.ERROR;
this.image_ = ol.ImageTile.blankImage;
this.unlistenImage_();
this.image_ = ol.ImageTile.blankImage;
this.changed();
};
@@ -149,7 +150,7 @@ ol.ImageTile.prototype.unlistenImage_ = function() {
/**
* A blank image.
* @type {Image}
* @type {HTMLCanvasElement}
*/
ol.ImageTile.blankImage = (function() {
var ctx = ol.dom.createCanvasContext2D(1, 1);