[Bf-blender-cvs] [f3934523946] master: Fix T81345, part two: crash in depsgraph when freeing COW armature.
Bastien Montagne
noreply at git.blender.org
Fri Oct 2 17:46:30 CEST 2020
Commit: f3934523946962b807b0dd7e0863a437cfc56e27
Author: Bastien Montagne
Date: Fri Oct 2 16:12:27 2020 +0200
Branches: master
https://developer.blender.org/rBf3934523946962b807b0dd7e0863a437cfc56e27
Fix T81345, part two: crash in depsgraph when freeing COW armature.
Freeing of bones' IDproerties from Armature `free_data` callback would always
attempt to do user refcounting, which should never be done from that code.
This would generate crashes in depsgraph/COW context e.g.
===================================================================
M source/blender/blenkernel/BKE_armature.h
M source/blender/blenkernel/intern/armature.c
M source/blender/editors/armature/armature_utils.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index d7ed92b69b7..975190f0fb5 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -141,7 +141,7 @@ typedef struct PoseTree {
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);
+void BKE_armature_bonelist_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 af9ce7c34ac..3d91d22e139 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -139,7 +139,7 @@ static void armature_free_data(struct ID *id)
bArmature *armature = (bArmature *)id;
BKE_armature_bone_hash_free(armature);
- BKE_armature_bonelist_free(&armature->bonebase);
+ BKE_armature_bonelist_free(&armature->bonebase, false);
/* free editmode data */
if (armature->edbo) {
@@ -357,15 +357,15 @@ int BKE_armature_bonelist_count(ListBase *lb)
return i;
}
-void BKE_armature_bonelist_free(ListBase *lb)
+void BKE_armature_bonelist_free(ListBase *lb, const bool do_id_user)
{
Bone *bone;
for (bone = lb->first; bone; bone = bone->next) {
if (bone->prop) {
- IDP_FreeProperty(bone->prop);
+ IDP_FreeProperty_ex(bone->prop, do_id_user);
}
- BKE_armature_bonelist_free(&bone->childbase);
+ BKE_armature_bonelist_free(&bone->childbase, do_id_user);
}
BLI_freelistN(lb);
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 1c8c5ba9d94..29df8b31819 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -695,7 +695,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
/* armature bones */
BKE_armature_bone_hash_free(arm);
- BKE_armature_bonelist_free(&arm->bonebase);
+ BKE_armature_bonelist_free(&arm->bonebase, true);
arm->act_bone = NULL;
/* remove zero sized bones, this gives unstable restposes */
More information about the Bf-blender-cvs
mailing list