[Bf-blender-cvs] [22f5edcf45e] blender-v2.82-release: Fix T71712: Free the dynamic mesh preview when rebuilding the PBVH

Pablo Dobarro noreply at git.blender.org
Tue Jan 14 20:18:01 CET 2020


Commit: 22f5edcf45e82b06ac70abfc542ae35169178506
Author: Pablo Dobarro
Date:   Fri Jan 10 18:05:57 2020 +0100
Branches: blender-v2.82-release
https://developer.blender.org/rB22f5edcf45e82b06ac70abfc542ae35169178506

Fix T71712: Free the dynamic mesh preview when rebuilding the PBVH

The PBVH usually is rebuild after a topology change, so it does not make
sense to keep the previous dynamic mesh preview vertex list. This may
cause a crash is the number of vertices of the new mesh (and preview) is
larger previous one. Now the list is deleted with the PBVH and a new one
will be generated using the new mesh when the cursor is updated.

Reviewed By: jbakker

Maniphest Tasks: T71712

Differential Revision: https://developer.blender.org/D6476

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

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

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

diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index a334a088e0f..46c2f735761 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1019,15 +1019,12 @@ static void sculptsession_free_pbvh(Object *object)
     ss->pbvh = NULL;
   }
 
-  if (ss->pmap) {
-    MEM_freeN(ss->pmap);
-    ss->pmap = NULL;
-  }
+  MEM_SAFE_FREE(ss->pmap);
 
-  if (ss->pmap_mem) {
-    MEM_freeN(ss->pmap_mem);
-    ss->pmap_mem = NULL;
-  }
+  MEM_SAFE_FREE(ss->pmap_mem);
+
+  MEM_SAFE_FREE(ss->preview_vert_index_list);
+  ss->preview_vert_index_count = 0;
 }
 
 void BKE_sculptsession_bm_to_me_for_render(Object *object)



More information about the Bf-blender-cvs mailing list