Fix #118637: crash after editbone duplication in certain case #118676

Merged
Philipp Oeser merged 2 commits from lichtwerk/blender:118637 into blender-v4.1-release 2024-02-26 17:41:05 +01:00
3 changed files with 9 additions and 1 deletions

View File

@ -87,7 +87,7 @@ FCurve *action_fcurve_ensure(Main *bmain,
agrp = action_groups_add_new(act, group);
/* Sync bone group colors if applicable. */
if (ptr && (ptr->type == &RNA_PoseBone)) {
if (ptr && (ptr->type == &RNA_PoseBone) && ptr->data) {
const bPoseChannel *pchan = static_cast<const bPoseChannel *>(ptr->data);
action_group_colors_set_from_posebone(agrp, pchan);
}

View File

@ -136,6 +136,8 @@ void action_group_colors_set(struct bActionGroup *grp, const struct BoneColor *c
*
* If `pchan->color` is set to a non-default color, that is used. Otherwise the
* armature bone color is used.
*
* Note that if `pchan->bone` is `nullptr`, this function silently does nothing.
*/
void action_group_colors_set_from_posebone(bActionGroup *grp, const bPoseChannel *pchan);

View File

@ -374,6 +374,12 @@ void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp)
void action_group_colors_set_from_posebone(bActionGroup *grp, const bPoseChannel *pchan)
{
BLI_assert_msg(pchan, "cannot 'set action group colors from posebone' without a posebone");
if (!pchan->bone) {
/* pchan->bone is only set after leaving editmode. */
return;
}
const BoneColor &color = blender::animrig::ANIM_bonecolor_posebone_get(pchan);
action_group_colors_set(grp, &color);
}