From 48f302b4fd1165bb4887f54929c6f665cc108f0e Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 13 May 2026 16:05:03 +0200 Subject: [PATCH] Fix rare asset loading problems --- Source/Engine/Content/Asset.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/Engine/Content/Asset.cpp b/Source/Engine/Content/Asset.cpp index da6b7329a..66ff7a93e 100644 --- a/Source/Engine/Content/Asset.cpp +++ b/Source/Engine/Content/Asset.cpp @@ -429,6 +429,9 @@ void Asset::Reload() ScopeLock lock(Locker); + // Cancel any still-running loading task (e.g. if WaitForLoaded timed out) + Platform::AtomicStore(&_loadingTask, 0); + if (IsLoaded()) { // Unload current data @@ -611,6 +614,13 @@ bool Asset::onLoad(LoadAssetTask* task) 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 LoadResult result; #if USE_EDITOR