[Bf-blender-cvs] [4b36552967b] master: Fix T81345: part three, armature `free_data` was not handling editbones properly.

Bastien Montagne noreply at git.blender.org
Fri Oct 2 17:46:30 CEST 2020


Commit: 4b36552967bf55b1bf707acd3917280b42b12c52
Author: Bastien Montagne
Date:   Fri Oct 2 17:36:13 2020 +0200
Branches: master
https://developer.blender.org/rB4b36552967bf55b1bf707acd3917280b42b12c52

Fix T81345: part three, armature `free_data` was not handling editbones properly.

Armature freeing would not correctly free its editbone IDProperties.

Add a utils to free the whole list of edit bones, and properly handle
their potential IDProperties.

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

M	source/blender/blenkernel/BKE_armature.h
M	source/blender/blenkernel/intern/armature.c

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

diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 975190f0fb5..092ca85a570 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -142,6 +142,7 @@ struct bArmature *BKE_armature_add(struct Main *bmain, const char *name);
 struct bArmature *BKE_armature_from_object(struct Object *ob);
 int BKE_armature_bonelist_count(struct ListBase *lb);
 void BKE_armature_bonelist_free(struct ListBase *lb, const bool do_id_user);
+void BKE_armature_editbonelist_free(struct ListBase *lb, const bool do_id_user);
 struct bArmature *BKE_armature_copy(struct Main *bmain, const struct bArmature *arm);
 
 void BKE_armature_copy_bone_transforms(struct bArmature *armature_dst,
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 3d91d22e139..0a731f0a7f0 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -143,8 +143,7 @@ static void armature_free_data(struct ID *id)
 
   /* free editmode data */
   if (armature->edbo) {
-    BLI_freelistN(armature->edbo);
-
+    BKE_armature_editbonelist_free(armature->edbo, false);
     MEM_freeN(armature->edbo);
     armature->edbo = NULL;
   }
@@ -371,6 +370,17 @@ void BKE_armature_bonelist_free(ListBase *lb, const bool do_id_user)
   BLI_freelistN(lb);
 }
 
+void BKE_armature_editbonelist_free(ListBase *lb, const bool do_id_user)
+{
+  LISTBASE_FOREACH_MUTABLE (EditBone *, edit_bone, lb) {
+    if (edit_bone->prop) {
+      IDP_FreeProperty_ex(edit_bone->prop, do_id_user);
+    }
+    BLI_remlink_safe(lb, edit_bone);
+    MEM_freeN(edit_bone);
+  }
+}
+
 static void copy_bonechildren(Bone *bone_dst,
                               const Bone *bone_src,
                               const Bone *bone_src_act,



More information about the Bf-blender-cvs mailing list