Fix loader reference key usage issue

This commit is contained in:
pandamicro
2017-01-18 14:58:44 +08:00
parent 688163fdf9
commit 00d01dc56d
2 changed files with 11 additions and 15 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]);
+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);
}
}