[Bf-blender-cvs] [8c4bd02b067] master: VSE: Delete Strip and Scene Data in one step

Antonio Vazquez noreply at git.blender.org
Mon May 16 20:20:50 CEST 2022


Commit: 8c4bd02b067af921d0a7dcbfc601bd0ef0941be1
Author: Antonio Vazquez
Date:   Mon May 16 20:19:33 2022 +0200
Branches: master
https://developer.blender.org/rB8c4bd02b067af921d0a7dcbfc601bd0ef0941be1

VSE: Delete Strip and Scene Data in one step

Actually, delete the strip only deletes the container, but not the linked data. This patch adds the option to delete the scene also. This is very handy for storyboarding.

Reviewed By: ISS

Maniphest Tasks: T97683

Differential Revision: https://developer.blender.org/D14794

===================================================================

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/editors/space_sequencer/sequencer_edit.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index b3d2cbf914a..f5f1ae14369 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -946,6 +946,9 @@ class SEQUENCER_MT_strip(Menu):
 
         strip = context.active_sequence_strip
 
+        if strip and strip.type == 'SCENE':
+            layout.operator("sequencer.delete", text="Delete Strip & Data").delete_data = True
+
         if has_sequencer:
             if strip:
                 strip_type = strip.type
@@ -1064,6 +1067,10 @@ class SEQUENCER_MT_context_menu(Menu):
         props.keep_open = False
         layout.operator("sequencer.delete", text="Delete")
 
+        strip = context.active_sequence_strip
+        if strip and strip.type == 'SCENE':
+            layout.operator("sequencer.delete", text="Delete Strip & Data").delete_data = True
+
         layout.separator()
 
         layout.operator("sequencer.slip", text="Slip Strip Contents")
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 0370d3605a7..4b72b989e80 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -57,6 +57,7 @@
 #include "ED_keyframing.h"
 #include "ED_numinput.h"
 #include "ED_outliner.h"
+#include "ED_scene.h"
 #include "ED_screen.h"
 #include "ED_sequencer.h"
 
@@ -1719,11 +1720,26 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot)
 /** \name Erase Strips Operator
  * \{ */
 
-static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
+static void sequencer_delete_strip_data(bContext *C, Sequence *seq)
+{
+  if (seq->type != SEQ_TYPE_SCENE) {
+    return;
+  }
+
+  Main *bmain = CTX_data_main(C);
+  if (seq->scene) {
+    if (ED_scene_delete(C, bmain, seq->scene)) {
+      WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, seq->scene);
+    }
+  }
+}
+
+static int sequencer_delete_exec(bContext *C, wmOperator *op)
 {
   Main *bmain = CTX_data_main(C);
   Scene *scene = CTX_data_scene(C);
   ListBase *seqbasep = SEQ_active_seqbase_get(SEQ_editing_get(scene));
+  const bool delete_data = RNA_boolean_get(op->ptr, "delete_data");
 
   if (sequencer_view_has_preview_poll(C) && !sequencer_view_preview_only_poll(C)) {
     return OPERATOR_CANCELLED;
@@ -1736,6 +1752,9 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
 
   SEQ_ITERATOR_FOREACH (seq, selected_strips) {
     SEQ_edit_flag_for_removal(scene, seqbasep, seq);
+    if (delete_data) {
+      sequencer_delete_strip_data(C, seq);
+    }
   }
   SEQ_edit_remove_flagged_sequences(scene, seqbasep);
 
@@ -1778,6 +1797,14 @@ void SEQUENCER_OT_delete(wmOperatorType *ot)
 
   /* Flags. */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+  /*  Properties. */
+  ot->prop = RNA_def_boolean(ot->srna,
+                             "delete_data",
+                             false,
+                             "Delete Data",
+                             "After removing the Strip, delete the associated data also");
+  RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
 }
 
 /** \} */



More information about the Bf-blender-cvs mailing list