From 9c7959153283e42f3cecc2739570a8c517f0dfcb Mon Sep 17 00:00:00 2001 From: pandamicro Date: Tue, 18 Oct 2016 10:56:10 +0800 Subject: [PATCH 1/2] Fix getRes for item not found --- cocos2d/core/load-pipeline/CCLoader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js index f15ed636b8..9d3dfd25d2 100644 --- a/cocos2d/core/load-pipeline/CCLoader.js +++ b/cocos2d/core/load-pipeline/CCLoader.js @@ -416,7 +416,7 @@ JS.mixin(CCLoader.prototype, { */ getRes: function (url) { var item = this._cache[url]; - if (item.alias) { + if (item && item.alias) { item = this._cache[item.alias]; } if (!item) { From 664c471cca5e97db40305def3db27372e98732f2 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Wed, 19 Oct 2016 16:11:58 +0800 Subject: [PATCH 2/2] Fix loader cache not been cleaned up in Editor --- cocos2d/core/load-pipeline/CCLoader.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js index 9d3dfd25d2..df9d7252c2 100644 --- a/cocos2d/core/load-pipeline/CCLoader.js +++ b/cocos2d/core/load-pipeline/CCLoader.js @@ -191,13 +191,13 @@ JS.mixin(CCLoader.prototype, { completeCallback.call(self, errors, items); } completeCallback = null; - items.destroy(); if (CC_EDITOR) { - for (var i = 0; i < resources.length; i++) { - self.removeItem(resources[i].id || resources[i]); + for (var id in self._cache) { + self.removeItem(id); } } + items.destroy(); }); }); }, @@ -435,13 +435,13 @@ JS.mixin(CCLoader.prototype, { }, /** - * Release the cache of resource by url. + * Release the cache of resource by id which is usually the url. * * @method release - * @param {String} url + * @param {String} id */ - release: function (url) { - this.removeItem(url); + release: function (id) { + this.removeItem(id); }, /**