diff --git a/source/blender/animrig/ANIM_animdata.hh b/source/blender/animrig/ANIM_animdata.hh index 59005f230dd..4cd4ee2ed14 100644 --- a/source/blender/animrig/ANIM_animdata.hh +++ b/source/blender/animrig/ANIM_animdata.hh @@ -33,6 +33,8 @@ bAction *id_action_ensure(Main *bmain, ID *id); /** * Delete the F-Curve from the given AnimData block (if possible), * as appropriate according to animation context. + * + * \note This function cannot be used to delete F-Curves from an NLA strip's Action. */ void animdata_fcurve_delete(AnimData *adt, FCurve *fcu); diff --git a/source/blender/editors/animation/anim_channels_edit.cc b/source/blender/editors/animation/anim_channels_edit.cc index a3b3e090efa..d3de3d24ce0 100644 --- a/source/blender/editors/animation/anim_channels_edit.cc +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -2941,7 +2941,22 @@ static wmOperatorStatus animchannels_delete_exec(bContext *C, wmOperator * /*op* /* try to free F-Curve */ BLI_assert_msg((fcu->driver != nullptr) == (ac.datatype == ANIMCONT_DRIVERS), "Expecting only driver F-Curves in the drivers editor"); - blender::animrig::animdata_fcurve_delete(adt, fcu); + if (ale->fcurve_owner_id && GS(ale->fcurve_owner_id->name) == ID_AC) { + /* F-Curves can be owned by Actions assigned to NLA strips, which + * `animrig::animdata_fcurve_delete()` (below) cannot handle. */ + BLI_assert_msg(!fcu->driver, "Drivers are not expected to be owned by Actions"); + blender::animrig::Action &action = + reinterpret_cast(ale->fcurve_owner_id)->wrap(); + BLI_assert(!action.is_action_legacy()); + action_fcurve_remove(action, *fcu); + } + else if (fcu->driver || adt->action) { + /* This function only works for drivers & directly-assigned Actions: */ + blender::animrig::animdata_fcurve_delete(adt, fcu); + } + else { + BLI_assert_unreachable(); + } tag_update_animation_element(ale); break; }