mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
Fixes to asset manager ref counter.
This commit is contained in:
parent
f4e375a2cd
commit
7dbcc39086
@ -337,6 +337,7 @@ export class AssetManagerBase implements Disposable {
|
|||||||
if (asset.dispose) asset.dispose();
|
if (asset.dispose) asset.dispose();
|
||||||
delete this.assets[path];
|
delete this.assets[path];
|
||||||
delete this.assetsRefCount[path];
|
delete this.assetsRefCount[path];
|
||||||
|
delete this.assetsLoaded[path];
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +347,8 @@ export class AssetManagerBase implements Disposable {
|
|||||||
if (asset.dispose) asset.dispose();
|
if (asset.dispose) asset.dispose();
|
||||||
}
|
}
|
||||||
this.assets = {};
|
this.assets = {};
|
||||||
|
this.assetsLoaded = {};
|
||||||
|
this.assetsRefCount = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoadingComplete (): boolean {
|
isLoadingComplete (): boolean {
|
||||||
@ -365,10 +368,9 @@ export class AssetManagerBase implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dispose asset only if it's not used by others
|
// dispose asset only if it's not used by others
|
||||||
disposeAsset(path: string, a?: string) {
|
disposeAsset(path: string) {
|
||||||
if (--this.assetsRefCount[path] === 0) {
|
if (--this.assetsRefCount[path] === 0) {
|
||||||
const asset = this.assets[path];
|
this.remove(path)
|
||||||
if (asset.dispose) asset.dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user