Fix rare asset loading problems

This commit is contained in:
2026-05-13 16:05:03 +02:00
parent d9c787a661
commit 48f302b4fd
+10
View File
@@ -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