diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index 2d1a3f74..e9bc2dcc 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -245,10 +245,11 @@ SGMaterial *SGMaterialLib::find( int lc, const SGGeod& center ) const SGMaterialCache *SGMaterialLib::generateMatCache(SGVec2f center, const simgear::SGReaderWriterOptions* options) { - std::lock_guard g(d->mutex); - SGMaterialCache* newCache = new SGMaterialCache(getMaterialTextureAtlas(center, options)); + + std::lock_guard g(d->mutex); + material_map::const_reverse_iterator it = matlib.rbegin(); for (; it != matlib.rend(); ++it) { newCache->insert(it->first, internalFind(it->first, center));