[Bf-blender-cvs] [e2e87efea28] blender-v2.90-release: Cleanup: Always keep unlock at same level as lock.

Bastien Montagne noreply at git.blender.org
Wed Jul 29 16:11:37 CEST 2020


Commit: e2e87efea28ce6acbb8bc13d1623735f8e6b4ff1
Author: Bastien Montagne
Date:   Wed Jul 29 10:31:37 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rBe2e87efea28ce6acbb8bc13d1623735f8e6b4ff1

Cleanup: Always keep unlock at same level as lock.

This was fine in those cases with current code, but that kind of
assumption is always risky, and an open door to hard-to-track bugs when
code changes in the future...

===================================================================

M	source/blender/blenkernel/intern/bvhutils.c

===================================================================

diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 93794eb9709..64c7b89bade 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -717,11 +717,14 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
       /* printf("BVHTree built and saved on cache\n"); */
       BVHCache *bvh_cache = *bvh_cache_p;
       bvhcache_insert(bvh_cache, tree, bvh_cache_type);
-      bvhcache_unlock(bvh_cache, lock_started);
       in_cache = true;
     }
   }
 
+  if (bvh_cache_p) {
+    bvhcache_unlock(*bvh_cache_p, lock_started);
+  }
+
   /* Setup BVHTreeFromMesh */
   bvhtree_from_mesh_verts_setup_data(data, tree, in_cache, vert, vert_allocated);
 
@@ -929,11 +932,14 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
       /* Save on cache for later use */
       /* printf("BVHTree built and saved on cache\n"); */
       bvhcache_insert(bvh_cache, tree, bvh_cache_type);
-      bvhcache_unlock(bvh_cache, lock_started);
       in_cache = true;
     }
   }
 
+  if (bvh_cache_p) {
+    bvhcache_unlock(*bvh_cache_p, lock_started);
+  }
+
   /* Setup BVHTreeFromMesh */
   bvhtree_from_mesh_edges_setup_data(
       data, tree, in_cache, vert, vert_allocated, edge, edge_allocated);
@@ -1058,11 +1064,14 @@ BVHTree *bvhtree_from_mesh_faces_ex(BVHTreeFromMesh *data,
       /* printf("BVHTree built and saved on cache\n"); */
       BVHCache *bvh_cache = *bvh_cache_p;
       bvhcache_insert(bvh_cache, tree, bvh_cache_type);
-      bvhcache_unlock(bvh_cache, lock_started);
       in_cache = true;
     }
   }
 
+  if (bvh_cache_p) {
+    bvhcache_unlock(*bvh_cache_p, lock_started);
+  }
+
   /* Setup BVHTreeFromMesh */
   bvhtree_from_mesh_faces_setup_data(
       data, tree, in_cache, vert, vert_allocated, face, face_allocated);
@@ -1298,11 +1307,14 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
     if (bvh_cache_p) {
       BVHCache *bvh_cache = *bvh_cache_p;
       bvhcache_insert(bvh_cache, tree, bvh_cache_type);
-      bvhcache_unlock(bvh_cache, lock_started);
       in_cache = true;
     }
   }
 
+  if (bvh_cache_p) {
+    bvhcache_unlock(*bvh_cache_p, lock_started);
+  }
+
   /* Setup BVHTreeFromMesh */
   bvhtree_from_mesh_looptri_setup_data(data,
                                        tree,



More information about the Bf-blender-cvs mailing list