Orange report bug; Adding a new scene, choose "link obdata" gives corrupt

memory. Poses should be relinked right after duplicating, not during a
redraw (when more objects use same armature).

Added in readfile a patch to make sure files saved with this duplicate
error can still be used.
This commit is contained in:
Ton Roosendaal 2005-09-29 16:37:37 +00:00
parent 76a57eb82f
commit 1ec6cc4986
5 changed files with 11 additions and 3 deletions

@ -933,7 +933,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int
return counter;
}
/* only after leave editmode, but also for validating older files */
/* only after leave editmode, duplicating, but also for validating older files */
/* NOTE: pose->flag is set for it */
void armature_rebuild_pose(Object *ob, bArmature *arm)
{

@ -820,7 +820,10 @@ Object *copy_object(Object *ob)
copy_controllers(&obn->controllers, &ob->controllers);
copy_actuators(&obn->actuators, &ob->actuators);
copy_pose(&obn->pose, ob->pose, 1);
if(ob->pose) {
copy_pose(&obn->pose, ob->pose, 1);
armature_rebuild_pose(obn, obn->data);
}
copy_defgroups(&obn->defbase, &ob->defbase);
copy_nlastrips(&obn->nlastrips, &ob->nlastrips);
copy_constraints (&obn->constraints, &ob->constraints);

@ -2266,6 +2266,7 @@ static void direct_link_pose(FileData *fd, bPose *pose) {
chan->parent= newdataadr(fd, chan->parent);
chan->child= newdataadr(fd, chan->child);
direct_link_constraints(fd, &chan->constraints);
chan->iktree.first= chan->iktree.last= NULL;
}
}

@ -3666,7 +3666,9 @@ void single_obdata_users(int flag)
ob->data= copy_lattice(ob->data);
break;
case OB_ARMATURE:
ob->data=copy_armature(ob->data);
ob->recalc |= OB_RECALC_DATA;
ob->data= copy_armature(ob->data);
armature_rebuild_pose(ob, ob->data);
break;
default:
printf("ERROR single_obdata_users: %s\n", id->name);
@ -4253,6 +4255,7 @@ void adduplicate(int noTrans)
ID_NEW_US2(obn->data )
else {
obn->data= copy_armature(obn->data);
armature_rebuild_pose(obn, obn->data);
didit= 1;
}
id->us--;

@ -1712,6 +1712,7 @@ void do_global_buttons2(short event)
if(arm->id.us>1) {
if(okee("Single user")) {
ob->data= copy_armature(arm);
armature_rebuild_pose(ob, ob->data);
arm->id.us--;
}
}