diff --git a/source/blender/animrig/intern/action.cc b/source/blender/animrig/intern/action.cc index 75e2cb331ac..9e4de3c55aa 100644 --- a/source/blender/animrig/intern/action.cc +++ b/source/blender/animrig/intern/action.cc @@ -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(ptr->data); action_group_colors_set_from_posebone(agrp, pchan); } diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index fb8dfea95c0..53fccbe3316 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -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); diff --git a/source/blender/blenkernel/intern/action.cc b/source/blender/blenkernel/intern/action.cc index 91fe3fbad05..49ecdb71169 100644 --- a/source/blender/blenkernel/intern/action.cc +++ b/source/blender/blenkernel/intern/action.cc @@ -375,6 +375,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); }