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 c4709a32f782c953f69a08e74e311e67fb68e91e..4651089a3900d60c005856a54f81696a9a2738d1 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;
 
        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)) {
                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;
                        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;
        }
 
        return collection->object_cache;