diff options
-rw-r--r-- | source/blender/blenkernel/BKE_action.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 23 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 7 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 28 |
4 files changed, 42 insertions, 22 deletions
diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 17b56864d1e..e0b65c1996f 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -118,6 +118,12 @@ struct bActionGroup *action_groups_find_named(struct bAction *act, const char na /* Pose API ----------------- */ /** + * Deallocates a pose channel. + * Does not free the pose channel itself. + */ +void free_pose_channel(struct bPoseChannel *pchan); + +/** * Removes and deallocates all channels from a pose. * Does not free the pose itself. */ diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 33f3658c53b..b359ab6ee87 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -62,6 +62,8 @@ #include "BKE_main.h" #include "BKE_object.h" #include "BKE_utildefines.h" +#include "BKE_idprop.h" + #include "BIK_api.h" #include "BLI_math.h" @@ -564,16 +566,27 @@ void init_pose_ikparam(bPose *pose) } } +void free_pose_channel(bPoseChannel *pchan) +{ + if (pchan->path) + MEM_freeN(pchan->path); + + free_constraints(&pchan->constraints); + + if(pchan->prop) { + IDP_FreeProperty(pchan->prop); + MEM_freeN(pchan->prop); + } +} + void free_pose_channels(bPose *pose) { bPoseChannel *pchan; if (pose->chanbase.first) { - for (pchan = pose->chanbase.first; pchan; pchan=pchan->next){ - if (pchan->path) - MEM_freeN(pchan->path); - free_constraints(&pchan->constraints); - } + for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) + free_pose_channel(pchan); + BLI_freelistN(&pose->chanbase); } } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 81630faccd1..a63ff4ed599 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1530,8 +1530,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected } /* free stuff from current channel */ - if (pchan->path) MEM_freeN(pchan->path); - free_constraints(&pchan->constraints); + free_pose_channel(pchan); /* the final copy */ *pchan= pchanw; @@ -1586,9 +1585,7 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) for(pchan= pose->chanbase.first; pchan; pchan= next) { next= pchan->next; if(pchan->bone==NULL) { - if(pchan->path) - MEM_freeN(pchan->path); - free_constraints(&pchan->constraints); + free_pose_channel(pchan); BLI_freelinkN(&pose->chanbase, pchan); } } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 320be365631..8c858536fc5 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -144,6 +144,11 @@ void free_edit_bone(bArmature *arm, EditBone *bone) if(arm->act_edbone==bone) arm->act_edbone= NULL; + if(bone->prop) { + IDP_FreeProperty(bone->prop); + MEM_freeN(bone->prop); + } + BLI_freelinkN(arm->edbo, bone); } @@ -1025,8 +1030,7 @@ static void separate_armature_bones (Scene *scene, Object *ob, short sel) } /* free any of the extra-data this pchan might have */ - if (pchan->path) MEM_freeN(pchan->path); - free_constraints(&pchan->constraints); + free_pose_channel(pchan); /* get rid of unneeded bone */ free_edit_bone(arm, curbone); @@ -1733,17 +1737,17 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *op) /* First erase any associated pose channel */ if (obedit->pose) { - bPoseChannel *chan, *next; - for (chan=obedit->pose->chanbase.first; chan; chan=next) { - next= chan->next; - curBone = editbone_name_exists(arm->edbo, chan->name); + bPoseChannel *pchan, *next; + for (pchan=obedit->pose->chanbase.first; pchan; pchan=next) { + next= pchan->next; + curBone = editbone_name_exists(arm->edbo, pchan->name); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { - free_constraints(&chan->constraints); - BLI_freelinkN (&obedit->pose->chanbase, chan); + free_pose_channel(pchan); + BLI_freelinkN (&obedit->pose->chanbase, pchan); } else { - for (con= chan->constraints.first; con; con= con->next) { + for (con= pchan->constraints.first; con; con= con->next) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -2522,12 +2526,12 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj * they point to has also been duplicated */ EditBone *oldtarget, *newtarget; - bPoseChannel *chan; + bPoseChannel *pchan; bConstraint *curcon; ListBase *conlist; - if ( (chan = verify_pose_channel(dst_ob->pose, dupBone->name)) ) { - if ( (conlist = &chan->constraints) ) { + if ( (pchan = verify_pose_channel(dst_ob->pose, dupBone->name)) ) { + if ( (conlist = &pchan->constraints) ) { for (curcon = conlist->first; curcon; curcon=curcon->next) { /* does this constraint have a subtarget in * this armature? |