From ec525fe7a9d5c46c10397ff0bcbecea7b20ef11c Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 2 Mar 2012 22:43:42 +0100 Subject: [PATCH] Fixed: #620 Incorrect usage of mutex in particle system loader --- code/nel/src/3d/particle_system_shape.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/code/nel/src/3d/particle_system_shape.cpp b/code/nel/src/3d/particle_system_shape.cpp index 5e41ba530..fb7aaa405 100644 --- a/code/nel/src/3d/particle_system_shape.cpp +++ b/code/nel/src/3d/particle_system_shape.cpp @@ -39,7 +39,11 @@ namespace NL3D { using NLMISC::CIFile; +namespace { +NLMISC::CMutex s_PSSMutex; + +} /* anonymous namespace */ // private usage : macro to check the memory integrity #if defined(NL_DEBUG) && defined(NL_OS_WINDOWS) @@ -220,9 +224,8 @@ CParticleSystem *CParticleSystemShape::instanciatePS(CScene &scene, NLMISC::CCon return _SharedSystem; } - // avoid prb with concurent thread (may append if an instance group containing ps is loaded in background) - NLMISC::CMutex mutex; - mutex.enter(); + // avoid prb with concurrent thread (may happen if an instance group containing ps is loaded in background) + s_PSSMutex.enter(); #ifdef PS_FAST_ALLOC @@ -295,7 +298,7 @@ CParticleSystem *CParticleSystemShape::instanciatePS(CScene &scene, NLMISC::CCon } #endif - mutex.leave(); + s_PSSMutex.leave(); /*NLMISC::TTicks end = NLMISC::CTime::getPerformanceTime(); nlinfo("instanciation time = %.2f", (float) (1000 * NLMISC::CTime::ticksToSecond(end - start))); */ @@ -390,8 +393,7 @@ void CParticleSystemShape::flushTextures(IDriver &driver, uint selectedTexture) } else { - NLMISC::CMutex mutex; - mutex.enter(); + s_PSSMutex.enter(); // must create an instance just to flush the textures CParticleSystem *myInstance = NULL; @@ -436,7 +438,7 @@ void CParticleSystemShape::flushTextures(IDriver &driver, uint selectedTexture) #ifdef PS_FAST_ALLOC PSBlockAllocator = NULL; #endif - mutex.leave(); + s_PSSMutex.leave(); } for(uint k = 0; k < _CachedTex.size(); ++k) {