diff --git a/components/terrain/terraingrid.cpp b/components/terrain/terraingrid.cpp index 5b1854abc..f40f3a388 100644 --- a/components/terrain/terraingrid.cpp +++ b/components/terrain/terraingrid.cpp @@ -260,17 +260,6 @@ void TerrainGrid::unloadCell(int x, int y) void TerrainGrid::updateCache() { - { - OpenThreads::ScopedLock lock(mTextureCacheMutex); - for (TextureCache::iterator it = mTextureCache.begin(); it != mTextureCache.end();) - { - if (it->second->referenceCount() <= 1) - mTextureCache.erase(it++); - else - ++it; - } - } - { OpenThreads::ScopedLock lock(mGridCacheMutex); for (Grid::iterator it = mGridCache.begin(); it != mGridCache.end();) @@ -281,6 +270,17 @@ void TerrainGrid::updateCache() ++it; } } + + { + OpenThreads::ScopedLock lock(mTextureCacheMutex); + for (TextureCache::iterator it = mTextureCache.begin(); it != mTextureCache.end();) + { + if (it->second->referenceCount() <= 1) + mTextureCache.erase(it++); + else + ++it; + } + } } }