Merge pull request #1447 from pandamicro/v1.4

修复资源释放问题,修复资源加载冲突问题
This commit is contained in:
Jare Guo
2017-01-18 15:32:58 +08:00
committed by GitHub
3 changed files with 15 additions and 21 deletions
+5 -9
View File
@@ -322,14 +322,10 @@ JS.mixin(CCLoader.prototype, {
else if (CC_DEV) {
cc.warnID(4800, assetOrUrlOrUuid);
}
var isUuid = cc.AssetLibrary._getAssetUrl(key);
if (isUuid) {
_info.url = null;
_info.raw = false;
cc.AssetLibrary._getAssetInfoInRuntime(key, _info);
key = _info.url;
}
return key;
_info.url = null;
_info.raw = false;
cc.AssetLibrary._getAssetInfoInRuntime(key, _info);
return this._cache[_info.url] ? _info.url : key;
},
/**
@@ -603,12 +599,12 @@ JS.mixin(CCLoader.prototype, {
if (item) {
var removed = this.removeItem(id);
asset = item.content;
// TODO: AUDIO
if (asset instanceof cc.Asset) {
if (CC_JSB && asset instanceof cc.SpriteFrame && removed) {
// for the "Temporary solution" in deserialize.js
asset.release();
}
// Audio
var urls = asset.rawUrls;
for (var i = 0; i < urls.length; i++) {
this.release(urls[i]);
+4 -6
View File
@@ -372,11 +372,11 @@ JS.mixin(Pipeline.prototype, {
},
/**
* !#en Removes an item in pipeline, no matter it's in progress or completed.
* !#en Removes an completed item in pipeline.
* It will only remove the cache in the pipeline or loader, its dependencies won't be released.
* cc.loader provided another method to completely cleanup the resource and its dependencies,
* please refer to {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
* !#zh 移除指定 item,无论是进行时还是已完成。
* !#zh 移除指定的已完成 item。
* 这将仅仅从 pipeline 或者 loader 中删除其缓存,并不会释放它所依赖的资源。
* cc.loader 中提供了另一种删除资源及其依赖的清理方法,请参考 {{#crossLink "loader/release:method"}}cc.loader.release{{/crossLink}}
* @method removeItem
@@ -385,10 +385,8 @@ JS.mixin(Pipeline.prototype, {
*/
removeItem: function (id) {
var removed = this._cache[id];
delete this._cache[id];
if (removed && !removed.complete) {
removed.error = new Error('Canceled manually');
this.flowOut(removed);
if (removed && removed.complete) {
delete this._cache[id];
}
return removed;
},
+6 -6
View File
@@ -88,12 +88,12 @@ var AssetLibrary = {
Editor.error('Sorry, the scene data of "%s" is corrupted!', uuid);
}
else {
// We know scene is not a raw asset, so we can pass uuid to this API directly
asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(uuid);
var key = cc.loader._getReferenceKey(uuid);
asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(key);
}
}
if (CC_EDITOR || isScene(asset)) {
var id = cc.AssetLibrary._getAssetInfoInRuntime(uuid).url;
var id = cc.loader._getReferenceKey(uuid);
Loader.removeItem(id);
}
}
@@ -220,11 +220,11 @@ var AssetLibrary = {
}
else {
if (asset.constructor === cc.SceneAsset) {
// We know scene is not a raw asset, so we can pass uuid to this API directly
asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(randomUuid);
var key = cc.loader._getReferenceKey(randomUuid);
asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(key);
}
if (CC_EDITOR || isScene(asset)) {
var id = cc.AssetLibrary._getAssetInfoInRuntime(randomUuid).url;
var id = cc.loader._getReferenceKey(randomUuid);
Loader.removeItem(id);
}
}