From 5f721c2e2e2bd3b4aaaee0639544b91c1b5989fa Mon Sep 17 00:00:00 2001 From: Falk David Date: Tue, 12 Aug 2025 18:55:26 +0200 Subject: [PATCH] Fix: VSE: Scene Strip template ID "new" function not working In the `Strip` panel in the scene template ID, the "new/duplicate" operator would duplicate the active scene in the window instead of the selected scene in the strip. Pull Request: https://projects.blender.org/blender/blender/pulls/144453 --- source/blender/editors/include/ED_scene.hh | 7 +--- source/blender/editors/scene/scene_edit.cc | 39 +++++++------------ .../editors/space_sequencer/sequencer_add.cc | 2 +- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/source/blender/editors/include/ED_scene.hh b/source/blender/editors/include/ED_scene.hh index 16fc115c09a..4c187ce79dc 100644 --- a/source/blender/editors/include/ED_scene.hh +++ b/source/blender/editors/include/ED_scene.hh @@ -20,12 +20,9 @@ struct Strip; Scene *ED_scene_add(Main *bmain, bContext *C, wmWindow *win, eSceneCopyMethod method) ATTR_NONNULL(); /** - * Add a new scene in the sequence editor. - * - * Special mode for adding a scene assigned to sequencer strip. + * Add a new scene from the sequence editor. */ -Scene *ED_scene_sequencer_add( - Main *bmain, bContext *C, Strip *active_strip, eSceneCopyMethod method, bool assign_strip); +Scene *ED_scene_sequencer_add(Main *bmain, bContext *C, eSceneCopyMethod method); /** * \note Only call outside of area/region loops. * \return true if successful. diff --git a/source/blender/editors/scene/scene_edit.cc b/source/blender/editors/scene/scene_edit.cc index 20b167bedfd..ead9ae6ed6b 100644 --- a/source/blender/editors/scene/scene_edit.cc +++ b/source/blender/editors/scene/scene_edit.cc @@ -65,33 +65,11 @@ static Scene *scene_add(Main *bmain, Scene *scene_old, eSceneCopyMethod method) return scene_new; } -Scene *ED_scene_sequencer_add( - Main *bmain, bContext *C, Strip *strip, eSceneCopyMethod method, const bool assign_strip) +Scene *ED_scene_sequencer_add(Main *bmain, bContext *C, eSceneCopyMethod method) { - Scene *sequencer_scene = CTX_data_sequencer_scene(C); Scene *active_scene = CTX_data_scene(C); - Scene *scene_new = scene_add(bmain, active_scene, method); - /* If don't need assign the scene to the strip, nothing else to do. */ - if (!assign_strip) { - return scene_new; - } - - /* As the scene is created in sequencer, do not set the new scene as active. - * This is useful for story-boarding where we want to keep actual scene active. - * The new scene is linked to the active strip and the viewport updated. */ - if (scene_new && strip) { - strip->scene = scene_new; - /* Do a refresh of the sequencer data. */ - blender::seq::relations_invalidate_cache_raw(sequencer_scene, strip); - DEG_id_tag_update(&sequencer_scene->id, ID_RECALC_AUDIO | ID_RECALC_SEQUENCER_STRIPS); - DEG_relations_tag_update(bmain); - } - - WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, sequencer_scene); - WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sequencer_scene); - return scene_new; } @@ -284,14 +262,23 @@ static wmOperatorStatus scene_new_sequencer_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); int type = RNA_enum_get(op->ptr, "type"); - Scene *scene = CTX_data_sequencer_scene(C); - Strip *strip = blender::seq::select_active_get(scene); + Scene *sequencer_scene = CTX_data_sequencer_scene(C); + Strip *strip = blender::seq::select_active_get(sequencer_scene); BLI_assert(strip != nullptr); - if (ED_scene_sequencer_add(bmain, C, strip, eSceneCopyMethod(type), true) == nullptr) { + if (!strip->scene) { return OPERATOR_CANCELLED; } + Scene *scene_new = scene_add(bmain, strip->scene, eSceneCopyMethod(type)); + if (!scene_new) { + return OPERATOR_CANCELLED; + } + strip->scene = scene_new; + /* Do a refresh of the sequencer data. */ + blender::seq::relations_invalidate_cache_raw(sequencer_scene, strip); + DEG_id_tag_update(&sequencer_scene->id, ID_RECALC_AUDIO | ID_RECALC_SEQUENCER_STRIPS); + DEG_relations_tag_update(bmain); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_sequencer/sequencer_add.cc b/source/blender/editors/space_sequencer/sequencer_add.cc index bfc204eee40..a5c5713dfe1 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.cc +++ b/source/blender/editors/space_sequencer/sequencer_add.cc @@ -731,7 +731,7 @@ static wmOperatorStatus sequencer_add_scene_strip_new_exec(bContext *C, wmOperat load_data_init_from_operator(&load_data, C, op); int type = RNA_enum_get(op->ptr, "type"); - Scene *scene_new = ED_scene_sequencer_add(bmain, C, nullptr, eSceneCopyMethod(type), false); + Scene *scene_new = ED_scene_sequencer_add(bmain, C, eSceneCopyMethod(type)); if (scene_new == nullptr) { return OPERATOR_CANCELLED; }