Fix incorrect double checked lock in collection object cache.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 6 Jun 2018 10:18:41 +0000 (12:18 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Wed, 6 Jun 2018 14:00:25 +0000 (16:00 +0200)
source/blender/blenkernel/intern/collection.c

index c4709a3..4651089 100644 (file)
@@ -367,12 +367,12 @@ ListBase BKE_collection_object_cache_get(Collection *collection)
        if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
                static ThreadMutex cache_lock = BLI_MUTEX_INITIALIZER;
 
+               BLI_mutex_lock(&cache_lock);
                if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
-                       BLI_mutex_lock(&cache_lock);
                        collection_object_cache_fill(&collection->object_cache, collection, 0);
                        collection->flag |= COLLECTION_HAS_OBJECT_CACHE;
-                       BLI_mutex_unlock(&cache_lock);
                }
+               BLI_mutex_unlock(&cache_lock);
        }
 
        return collection->object_cache;