Fix T37289: ID User decrement error for Shapes on Bones when playing in BGE

GE was copying the pose channels without increasing user counter for a
custom bone shape object. Freeing copied pose will for give decrement
errors.

The same increment issue seems to happen in BKE_pose_copy_data, which
is also solved now.
This commit is contained in:
Sergey Sharybin 2013-11-18 17:17:43 +06:00
parent ea79dcebe2
commit 2b0162b622
Notes: blender-bot 2023-02-14 11:39:16 +01:00
Referenced by issue #37289, ID User decrement error for Shapes on Bones when playing in BGE
2 changed files with 14 additions and 1 deletions

View File

@ -589,7 +589,15 @@ void BKE_pose_copy_data(bPose **dst, bPose *src, const bool copy_constraints)
outPose = MEM_callocN(sizeof(bPose), "pose");
BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
if (outPose->chanbase.first) {
bPoseChannel *pchan;
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->custom) {
id_us_plus(&pchan->custom->id);
}
}
}
outPose->iksolver = src->iksolver;
outPose->ikdata = NULL;
outPose->ikparam = MEM_dupallocN(src->ikparam);

View File

@ -42,6 +42,7 @@
#include "BIK_api.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_library.h"
#include "BKE_constraint.h"
#include "CTR_Map.h"
@ -120,6 +121,10 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
pchan->constraints.last = NULL;
}
if (pchan->custom) {
id_us_plus(&pchan->custom->id);
}
// fails to link, props are not used in the BGE yet.
#if 0
if (pchan->prop)