Fix T94295: VSE fades error when no suitable sequences selected

This errored out in two scenarios:
- current frame not in strips framerange (this was reported)
- no strips selected at all

Now handle these cases properly in the operator and give appropriate
report info.

Maniphest Tasks: T94295

Differential Revision: https://developer.blender.org/D13642
This commit is contained in:
Philipp Oeser 2021-12-21 13:42:08 +01:00
parent d2bf60cc17
commit 2ce2bffc4d
Notes: blender-bot 2023-02-14 07:47:59 +01:00
Referenced by issue #94295, VSE Add menu, Fade From current Frame and To current Frame error with zero duration
1 changed files with 8 additions and 0 deletions

View File

@ -216,11 +216,19 @@ class SequencerFadesAdd(Operator):
scene.animation_data.action = action
sequences = context.selected_sequences
if not sequences:
self.report({'ERROR'}, "No sequences selected")
return {'CANCELLED'}
if self.type in {'CURSOR_TO', 'CURSOR_FROM'}:
sequences = [
strip for strip in sequences
if strip.frame_final_start < scene.frame_current < strip.frame_final_end
]
if not sequences:
self.report({'ERROR'}, "Current frame not within strip framerange")
return {'CANCELLED'}
max_duration = min(sequences, key=lambda strip: strip.frame_final_duration).frame_final_duration
max_duration = floor(max_duration / 2.0) if self.type == 'IN_OUT' else max_duration