[Bf-blender-cvs] [dfbcbaf7eb9] fracture_modifier: fix attempt for memory leak after loading FM blends in prefractured mode

Martin Felke noreply at git.blender.org
Sat Jun 17 21:09:17 CEST 2017


Commit: dfbcbaf7eb99b827144f7f47aa963873e56fd97a
Author: Martin Felke
Date:   Sat Jun 17 21:08:54 2017 +0200
Branches: fracture_modifier
https://developer.blender.org/rBdfbcbaf7eb99b827144f7f47aa963873e56fd97a

fix attempt for memory leak after loading FM blends in prefractured mode

note: works only with newly saved FM files, older still have unnecessary data in them which wont be automatically cleaned

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

M	source/blender/blenkernel/intern/fracture.c
M	source/blender/modifiers/intern/MOD_fracture.c

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

diff --git a/source/blender/blenkernel/intern/fracture.c b/source/blender/blenkernel/intern/fracture.c
index a5a564c917c..c8401d94583 100644
--- a/source/blender/blenkernel/intern/fracture.c
+++ b/source/blender/blenkernel/intern/fracture.c
@@ -1922,7 +1922,7 @@ void BKE_fracmesh_free(FracMesh *fm, bool doCustomData)
 
 	while (fm->shard_map.first) {
 		Shard* s = (Shard*)fm->shard_map.first;
-		BLI_remlink_safe(&fm->shard_map, s);
+		BLI_remlink(&fm->shard_map, s);
 		BKE_shard_free(s, doCustomData);
 	}
 
diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index c7df550bc0c..4a3d9f534fc 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -96,6 +96,7 @@ static void do_halving(FractureModifierData *fmd, Object* ob, DerivedMesh *dm, D
 static void free_shared_verts(ListBase *lb);
 static void reset_automerge(FractureModifierData *fmd);
 static void do_refresh_automerge(FractureModifierData *fmd);
+static void free_shards(FractureModifierData *fmd);
 
 typedef struct SharedVertGroup {
 	struct SharedVertGroup* next, *prev;
@@ -512,11 +513,10 @@ static void free_modifier(FractureModifierData *fmd, bool do_free_seq, bool do_f
 			fmd->visible_mesh_cached->release(fmd->visible_mesh_cached);
 			fmd->visible_mesh_cached = NULL;
 		}
-
-		if (fmd->fracture_mode == MOD_FRACTURE_EXTERNAL)
-			free_shards(fmd);
 	}
 
+	free_shards(fmd);
+
 	if (fmd->vert_index_map != NULL) {
 		BLI_ghash_free(fmd->vert_index_map, NULL, NULL);
 		fmd->vert_index_map = NULL;
@@ -567,7 +567,7 @@ static void freeData(ModifierData *md)
 {
 	FractureModifierData *fmd = (FractureModifierData *) md;
 
-	freeData_internal(fmd, true, false);
+	freeData_internal(fmd, fmd->fracture_mode == MOD_FRACTURE_DYNAMIC, false);
 
 	/*force deletion of meshshards here, it slips through improper state detection*/
 	/*here we know the modifier is about to be deleted completely*/




More information about the Bf-blender-cvs mailing list