Fix crash in particles system when assets gets loading/unloaded while async jobs are active

This commit is contained in:
Wojtek Figat
2025-02-18 23:27:49 +01:00
parent 060bc0aaf8
commit 937d369856
5 changed files with 26 additions and 3 deletions

View File

@@ -72,6 +72,8 @@ namespace
Asset::LoadResult ParticleEmitter::load()
{
ConcurrentSystemLocker::WriteScope systemScope(Particles::SystemLocker);
// Load the graph
const auto surfaceChunk = GetChunk(SHADER_FILE_CHUNK_VISJECT_SURFACE);
if (!surfaceChunk)
@@ -287,6 +289,7 @@ Asset::LoadResult ParticleEmitter::load()
void ParticleEmitter::unload(bool isReloading)
{
ConcurrentSystemLocker::WriteScope systemScope(Particles::SystemLocker);
#if COMPILE_WITH_SHADER_COMPILER
UnregisterForShaderReloads(this);
#endif
@@ -389,7 +392,7 @@ bool ParticleEmitter::SaveSurface(BytesContainer& data)
LOG(Error, "Asset loading failed. Cannot save it.");
return true;
}
ConcurrentSystemLocker::WriteScope systemScope(Particles::SystemLocker);
ScopeLock lock(Locker);
// Release all chunks