[Bf-blender-cvs] [711bcef7f4b] sculpt-dev: Sculpt-dev: Yet another pbvh cache crash

Joseph Eagar noreply at git.blender.org
Thu Mar 24 18:46:36 CET 2022


Commit: 711bcef7f4b3a6126f59c7609f3754a16c33dfc4
Author: Joseph Eagar
Date:   Thu Mar 24 10:46:11 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB711bcef7f4b3a6126f59c7609f3754a16c33dfc4

Sculpt-dev: Yet another pbvh cache crash

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

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

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

diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 88cdd3dc713..57252de117d 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -4945,19 +4945,29 @@ ATTR_NO_OPT bool BKE_pbvh_cache_is_valid(const Object *ob,
 GHash *cached_pbvhs = NULL;
 static void pbvh_clear_cached_pbvhs(PBVH *exclude)
 {
+  PBVH **pbvhs = NULL;
+  BLI_array_staticdeclare(pbvhs, 8);
+
   GHashIterator iter;
   GHASH_ITER (iter, cached_pbvhs) {
     PBVH *pbvh = BLI_ghashIterator_getValue(&iter);
 
     if (pbvh != exclude) {
-      if (pbvh->bm) {
-        BM_mesh_free(pbvh->bm);
-      }
+      BLI_array_append(pbvhs, pbvh);
+    }
+  }
 
-      BKE_pbvh_free(pbvh);
+  for (int i = 0; i < BLI_array_len(pbvhs); i++) {
+    PBVH *pbvh = pbvhs[i];
+
+    if (pbvh->bm) {
+      BM_mesh_free(pbvh->bm);
     }
+
+    BKE_pbvh_free(pbvh);
   }
 
+  BLI_array_free(pbvhs);
   BLI_ghash_clear(cached_pbvhs, MEM_freeN, NULL);
 }



More information about the Bf-blender-cvs mailing list