Fix #139762: Deleting an F-Curve from NLA strip in tweak mode crashes
The "delete this F-Curve" function assumes that the F-Curve is either a driver or contained in `adt->action`. This does not have to be true, as the Action editor can also show F-Curves from other uses (for example an NLA strip). The channel delete operator (`ANIM_OT_channels_delete`) now takes this into account. Pull Request: https://projects.blender.org/blender/blender/pulls/140291
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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<bAction *>(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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user