Issue fixes for Image cache, ParticleSystem & loadResDir (#2997)

* Remove Image object from loader cache when cleanup

* Fix ParticleSystem still render after uncheck preview

* Fix issue when loadResDir not passing completeCallback
This commit is contained in:
pandamicro
2018-07-19 11:28:09 +08:00
committed by GitHub
parent edf97a422d
commit 41fe03e392
4 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -537,10 +537,12 @@ var Texture2D = cc.Class({
this.loaded = true;
this.emit("load");
if (cc.macro.CLEANUP_IMAGE_CACHE) {
if (cc.macro.CLEANUP_IMAGE_CACHE && this._image instanceof HTMLImageElement) {
// wechat game platform will cache image parsed data,
// so image will consume much more memory than web, releasing it
this._image.src = "";
// Release image in loader cache
cc.loader.removeItem(this._image.id);
}
},
+1 -1
View File
@@ -656,7 +656,7 @@ proto.loadResDir = function (url, type, progressCallback, completeCallback) {
}
}
}
completeCallback(errors, assetRes, urlRes);
completeCallback && completeCallback(errors, assetRes, urlRes);
}, urls);
};
+1
View File
@@ -101,6 +101,7 @@ function downloadImage (item, callback, isCrossOrigin, img) {
img.removeEventListener('load', loadCallback);
img.removeEventListener('error', errorCallback);
img.id = item.id;
callback(null, img);
}
function errorCallback () {
+1
View File
@@ -130,6 +130,7 @@ var properties = {
this.resetSystem();
if ( !this.preview ) {
this.stopSystem();
this.disableRender();
}
cc.engine.repaintInEditMode();
},