mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Fixed Assets being registered for two IDs, getting Asset for Id 0 now returns null.
This commit is contained in:
@@ -365,6 +365,11 @@ class EditorContentManager : IContentManager
|
|||||||
{
|
{
|
||||||
Asset asset = null;
|
Asset asset = null;
|
||||||
|
|
||||||
|
if (handle == .Invalid)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_handleToAsset.TryGetValue(handle, out asset))
|
if (!_handleToAsset.TryGetValue(handle, out asset))
|
||||||
{
|
{
|
||||||
AssetHandle handleAfterLoading = LoadAsset(handle, blocking);
|
AssetHandle handleAfterLoading = LoadAsset(handle, blocking);
|
||||||
@@ -373,9 +378,10 @@ class EditorContentManager : IContentManager
|
|||||||
{
|
{
|
||||||
// TODO: If the asset existed at some point, the cache might still know of it.
|
// TODO: If the asset existed at some point, the cache might still know of it.
|
||||||
// Or we store the asset name somewhere else. (For the editor in the asset using it?)
|
// Or we store the asset name somewhere else. (For the editor in the asset using it?)
|
||||||
asset = new NewPlaceholderAsset(handle, .Error);
|
using(asset = new NewPlaceholderAsset(handle, .Error))
|
||||||
|
{
|
||||||
AssignHandleAndManage(asset, handle);
|
AssignHandleAndManage(asset, handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,11 +651,7 @@ class EditorContentManager : IContentManager
|
|||||||
using (_finishedEntriesLock.Enter())
|
using (_finishedEntriesLock.Enter())
|
||||||
{
|
{
|
||||||
loadedAsset.Identifier = assetNode.Identifier;
|
loadedAsset.Identifier = assetNode.Identifier;
|
||||||
// TODO: AssignHandleAndManage
|
AssignHandleAndManage(loadedAsset, handle);
|
||||||
loadedAsset.[Friend]_contentManager = this;
|
|
||||||
loadedAsset.[Friend]_handle = handle;
|
|
||||||
|
|
||||||
_handleToAsset.Add(handle, loadedAsset);
|
|
||||||
_identiferToHandle.Add(loadedAsset.Identifier, handle);
|
_identiferToHandle.Add(loadedAsset.Identifier, handle);
|
||||||
|
|
||||||
file.[Friend]_loadedAsset = loadedAsset;
|
file.[Friend]_loadedAsset = loadedAsset;
|
||||||
@@ -904,6 +906,12 @@ class EditorContentManager : IContentManager
|
|||||||
|
|
||||||
private void AssignHandleAndManage(Asset asset, AssetHandle handle)
|
private void AssignHandleAndManage(Asset asset, AssetHandle handle)
|
||||||
{
|
{
|
||||||
|
if (_handleToAsset.Remove(asset.Handle))
|
||||||
|
{
|
||||||
|
// We need to remove one ref, but it might be the only one, so defer it.
|
||||||
|
defer:: asset.ReleaseRef();
|
||||||
|
}
|
||||||
|
|
||||||
if (_handleToAsset.TryGetValue(handle, let existingAsset))
|
if (_handleToAsset.TryGetValue(handle, let existingAsset))
|
||||||
{
|
{
|
||||||
existingAsset.ReleaseRef();
|
existingAsset.ReleaseRef();
|
||||||
|
|||||||
Reference in New Issue
Block a user