Added a mutex to ensure_materials_loaded in PropCache. This fixes potential "ERROR: Another resource is loaded from path" when spawning lots of PropInstanceMergers for the first time.

This commit is contained in:
Relintai 2021-08-25 01:20:12 +02:00
parent a0153bbe0b
commit 4be30142fb
2 changed files with 7 additions and 1 deletions

View File

@ -41,8 +41,8 @@ SOFTWARE.
#include "../../thread_pool/thread_pool.h"
#endif
#include "../tiled_wall/tiled_wall_data.h"
#include "../material_cache/prop_material_cache.h"
#include "../tiled_wall/tiled_wall_data.h"
#include "core/hashfuncs.h"
@ -170,9 +170,13 @@ void PropCache::materials_load() {
}
void PropCache::ensure_materials_loaded() {
_material_mutex.lock();
if (_materials.size() != _material_paths.size()) {
materials_load();
}
_material_mutex.unlock();
}
Vector<Variant> PropCache::materials_get() {

View File

@ -122,6 +122,8 @@ protected:
Mutex _tiled_wall_material_cache_mutex;
Mutex _custom_keyed_material_cache_mutex;
Mutex _material_mutex;
#ifdef TEXTURE_PACKER_PRESENT
int _texture_flags;
int _max_atlas_size;