GDQuest / blender-power-sequencer

Add-on for video editing in Blender 3D: edit videos faster! Included in Blender 2.81+
https://gdquest.com/blender/power-sequencer/
GNU General Public License v3.0
708 stars 58 forks source link

Channel offset operator not removing strips #452

Closed RichardAntalik closed 3 years ago

RichardAntalik commented 3 years ago

In issue #447 I have provided patch, but unfortunately it wasn't quite correct and I did not test it. Sorry for that :(. But also never trust any code no matter how good it looks :)

byp.context.sequences is just generated collection of strips with no API functions. it happens to have remove() function, but that is collection internal function for managing members.

So this is mildly annoying, that to use API function, you have to find actual sequences collection that belongs to meta strip. Here is patch for that, I have actually tested, but don't trust me anyway.

Also sorry for delay, I forgot to save todo list so I almost forgot about this issue. It's best to report even small bugs on tracker.

diff --git a/power_sequencer/operators/utils/functions.py b/power_sequencer/operators/utils/functions.py
index 021dfd54..ea43ff7f 100644
--- a/power_sequencer/operators/utils/functions.py
+++ b/power_sequencer/operators/utils/functions.py
@@ -252,6 +252,25 @@ def slice_selection(context, sequences, range_block=0):
     return broken_selection

+def find_sequences_by_strip(sequences, strip):
+    for strip_iter in sequences:
+        if strip_iter == strip:
+            return sequences
+
+        if strip_iter.type == 'META':
+            meta_sequences = find_sequences_by_strip(strip_iter.sequences, strip)
+            if meta_sequences is not None:
+                return meta_sequences
+
+    return None
+
+
+
+def remove_strip(context, strip):
+    sequences = find_sequences_by_strip(context.scene.sequence_editor.sequences, strip)
+    sequences.remove(strip)
+
+
 def trim_strips(context, frame_start, frame_end, to_trim, to_delete=[]):
     """
     Removes the footage and audio between frame_start and frame_end.
@@ -291,7 +310,7 @@ def trim_strips(context, frame_start, frame_end, to_trim, to_delete=[]):
             s.frame_final_end = trim_start

     for s in to_delete:
-        bpy.context.sequences.remove(s)
+        remove_strip(context, s)

     for s in initial_selection:
         s.select = True
NathanLovato commented 3 years ago

In which version of blender are you having this bug? And would you have a list of reproducible steps for me?

I need to be able to reproduce the bug to test it; so far everything's working as expected for me here.

RichardAntalik commented 3 years ago

It's issue you have reported to me in https://blender.chat/channel/vse?msg=BPrmy8H3mXoTe2QKk

Hi Richard, someone reported an issue with the Python code change you requested in 2.93 alpha. Deleting strips like so doesn't work:

Edit: added snippet in case link is not working

NathanLovato commented 3 years ago

Ah sorry Richard, I didn't read your nickname, it's early morning here. So the bug @GTaulats is facing didn't involve any meta strips, but that's good to know.

I just did a minimal test and indeed it seems using bpy.context.scene.sequence_editor.sequences as opposed to bpy.context.sequences makes a difference.

@GTaulats would you try with just using bpy.context.scene.sequence_editor.sequences and see if it solves the issue you had?

NathanLovato commented 3 years ago

Fixed with a86a3274631c56ff29aa666717cbfbf41550d334