diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index ee0e72e0b5d..4c2eecc6eb1 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -86,6 +86,8 @@ #include "BKE_unit.hh" #include "BKE_workspace.hh" +#include "ANIM_action.hh" + #include "DEG_depsgraph.hh" #include "DEG_depsgraph_build.hh" #include "DEG_depsgraph_debug.hh" @@ -1597,14 +1599,26 @@ const char *RE_engine_id_CYCLES = "CYCLES"; static void remove_sequencer_fcurves(Scene *sce) { - AnimData *adt = BKE_animdata_from_id(&sce->id); + using namespace blender; - if (adt && adt->action) { - LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, &adt->action->curves) { - if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { - action_groups_remove_channel(adt->action, fcu); - BKE_fcurve_free(fcu); - } + std::optional> action_and_slot = + animrig::get_action_slot_pair(sce->id); + if (!action_and_slot) { + return; + } + + animrig::Channelbag *channelbag = channelbag_for_action_slot(*action_and_slot->first, + action_and_slot->second->handle); + if (!channelbag) { + return; + } + + /* Create a copy of the F-Curve pointers, so iteration is safe while they are removed. */ + Vector fcurves = channelbag->fcurves(); + + for (FCurve *fcurve : fcurves) { + if ((fcurve->rna_path) && strstr(fcurve->rna_path, "sequence_editor.strips_all")) { + channelbag->fcurve_remove(*fcurve); } } }