Fix rare asset loading problems
This commit is contained in:
@@ -429,6 +429,9 @@ void Asset::Reload()
|
|||||||
|
|
||||||
ScopeLock lock(Locker);
|
ScopeLock lock(Locker);
|
||||||
|
|
||||||
|
// Cancel any still-running loading task (e.g. if WaitForLoaded timed out)
|
||||||
|
Platform::AtomicStore(&_loadingTask, 0);
|
||||||
|
|
||||||
if (IsLoaded())
|
if (IsLoaded())
|
||||||
{
|
{
|
||||||
// Unload current data
|
// Unload current data
|
||||||
@@ -611,6 +614,13 @@ bool Asset::onLoad(LoadAssetTask* task)
|
|||||||
|
|
||||||
Locker.Lock();
|
Locker.Lock();
|
||||||
|
|
||||||
|
// Re-check after acquiring lock (loading task may have been cleared by Reload, or replaced by a new task)
|
||||||
|
if (Platform::AtomicRead(&_loadingTask) == 0)
|
||||||
|
{
|
||||||
|
Locker.Unlock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Load asset
|
// Load asset
|
||||||
LoadResult result;
|
LoadResult result;
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
|
|||||||
Reference in New Issue
Block a user