[Bf-blender-cvs] [8cea11e] fracture_modifier: memoryleak fix, forgot to free nor_tree in some cases

Martin Felke noreply at git.blender.org
Sat Oct 11 15:23:06 CEST 2014


Commit: 8cea11e1a7afe3a625e2f4df6764b22c9ea130b8
Author: Martin Felke
Date:   Sat Oct 11 15:22:25 2014 +0200
Branches: fracture_modifier
https://developer.blender.org/rB8cea11e1a7afe3a625e2f4df6764b22c9ea130b8

memoryleak fix, forgot to free nor_tree in some cases

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

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

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

diff --git a/source/blender/modifiers/intern/MOD_fracture.c b/source/blender/modifiers/intern/MOD_fracture.c
index 23ef07f..3dc8280 100644
--- a/source/blender/modifiers/intern/MOD_fracture.c
+++ b/source/blender/modifiers/intern/MOD_fracture.c
@@ -206,8 +206,7 @@ static void freeData(ModifierData *md)
 
 	/* refreshing all simulation data, no refracture */
 	if (!rmd->refresh_constraints) {
-		if (rmd->shards_to_islands)
-		{
+		if (rmd->shards_to_islands) {
 			while (rmd->islandShards.first) {
 				Shard *s = rmd->islandShards.first;
 				BLI_remlink(&rmd->islandShards, s);
@@ -579,6 +578,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
 	{
 		if (fmd->refresh) {
 			/* build normaltree from origdm */
+			if (fmd->nor_tree != NULL) {
+				BLI_kdtree_free(fmd->nor_tree);
+				fmd->nor_tree = NULL;
+			}
+
 			fmd->nor_tree = build_nor_tree(clean_dm);
 			if (fmd->face_pairs != NULL) {
 				BLI_ghash_free(fmd->face_pairs, NULL, NULL);
@@ -666,6 +670,11 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob,
 	{
 		if (fmd->refresh) {
 			/* build normaltree from origdm */
+			if (fmd->nor_tree != NULL) {
+				BLI_kdtree_free(fmd->nor_tree);
+				fmd->nor_tree = NULL;
+			}
+
 			fmd->nor_tree = build_nor_tree(clean_dm);
 			if (fmd->face_pairs != NULL) {
 				BLI_ghash_free(fmd->face_pairs, NULL, NULL);




More information about the Bf-blender-cvs mailing list