From 4f01f758aeddff8671f9110f49c876eef4bdcf84 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Sun, 1 Aug 2021 20:47:38 +0100 Subject: [PATCH] WS30: Fix deadlock introduced by fb436be8f1b47220ed7c8921c641869cdee5cb22 --- simgear/scene/material/matlib.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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));