[Bf-blender-cvs] [9db772fe9af] master: Fix T66991 Crash when deleting edit bones when pchan is referenced by bendybone

Clément Foucault noreply at git.blender.org
Mon Jul 15 15:15:26 CEST 2019


Commit: 9db772fe9afea62657ccdfaeda0bff8700c490ef
Author: Clément Foucault
Date:   Mon Jul 15 15:13:33 2019 +0200
Branches: master
https://developer.blender.org/rB9db772fe9afea62657ccdfaeda0bff8700c490ef

Fix T66991 Crash when deleting edit bones when pchan is referenced by bendybone

This was caused by loose pointers.

This diff takes care of clearing the fields of other bones before deleting the pchan.

Reviewers: brecht, sergey

Reviewed By: brecht, sergey

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

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

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

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

diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 6dd4eefc014..3e3a533275b 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -729,6 +729,21 @@ void BKE_pose_channels_hash_free(bPose *pose)
   }
 }
 
+static void pose_channels_remove_internal_links(Object *ob, bPoseChannel *unlinked_pchan)
+{
+  LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
+    if (pchan->bbone_prev == unlinked_pchan) {
+      pchan->bbone_prev = NULL;
+    }
+    if (pchan->bbone_next == unlinked_pchan) {
+      pchan->bbone_next = NULL;
+    }
+    if (pchan->custom_tx == unlinked_pchan) {
+      pchan->custom_tx = NULL;
+    }
+  }
+}
+
 /**
  * Selectively remove pose channels.
  */
@@ -747,6 +762,7 @@ void BKE_pose_channels_remove(Object *ob,
       if (filter_fn(pchan->name, user_data)) {
         /* Bone itself is being removed */
         BKE_pose_channel_free(pchan);
+        pose_channels_remove_internal_links(ob, pchan);
         if (ob->pose->chanhash) {
           BLI_ghash_remove(ob->pose->chanhash, pchan->name, NULL, NULL);
         }



More information about the Bf-blender-cvs mailing list