Bugfix: 'Random' crashes after duplicating bones

This commit should fix some seemingly random crashes broken and I have been experiencing while editing armatures.

A backtrace revealed that autosave was choking on the PoseChannels that didn't have a Bone assigned to them. This was caused by the bone duplication code making a new PoseChannel for a duplicated bone, but that new bone not getting assigned to the PoseChannel yet, as the user was still in EditMode.
This commit is contained in:
Joshua Leung
2007-07-04 07:07:12 +00:00
parent 727216f9e1
commit d846d9db9f
2 changed files with 14 additions and 10 deletions

View File

@@ -767,21 +767,23 @@ static void write_constraints(WriteData *wd, ListBase *conlist)
static void write_pose(WriteData *wd, bPose *pose)
{
bPoseChannel *chan;
bPoseChannel *chan;
/* Write each channel */
if (!pose)
return;
// Write channels
/* Write channels */
for (chan=pose->chanbase.first; chan; chan=chan->next) {
write_constraints(wd, &chan->constraints);
chan->selectflag= chan->bone->flag & (BONE_SELECTED|BONE_ACTIVE); // gets restored on read, for library armatures
/* prevent crashes with autosave, when a bone duplicated in editmode has not yet been assigned to its posechannel */
if (chan->bone)
chan->selectflag= chan->bone->flag & (BONE_SELECTED|BONE_ACTIVE); /* gets restored on read, for library armatures */
writestruct(wd, DATA, "bPoseChannel", 1, chan);
}
// Write this pose
/* Write this pose */
writestruct(wd, DATA, "bPose", 1, pose);
}

View File

@@ -1615,9 +1615,9 @@ void adduplicate_armature(void)
if (!firstDup)
firstDup=eBone;
/* Lets duplicate the list of constraits that the
* current bone has.
*/
/* Lets duplicate the list of constraints that the
* current bone has.
*/
if (OBACT->pose) {
bPoseChannel *chanold, *channew;
ListBase *listold, *listnew;
@@ -1625,7 +1625,10 @@ void adduplicate_armature(void)
chanold = verify_pose_channel (OBACT->pose, curBone->name);
if (chanold) {
listold = &chanold->constraints;
if (listold){
if (listold) {
/* WARNING: this creates a new posechannel, but there will not be an attached bone
* yet as the new bones created here are still 'EditBones' not 'Bones'.
*/
channew =
verify_pose_channel(OBACT->pose, eBone->name);
if (channew) {
@@ -1646,7 +1649,6 @@ void adduplicate_armature(void)
}
}
}
}
}
}