diff options
author | Richard Antalik <richardantalik@gmail.com> | 2022-09-17 04:38:38 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2022-09-21 13:52:12 +0300 |
commit | 41527ea89c7ab99737c8ba598f649d20bd7df972 (patch) | |
tree | cdc064cc45152db3e8f0c379ae8babc8f799b6a0 /source/blender/sequencer | |
parent | b50c1ca8fe2f44ed01b281406330aa13d3583e71 (diff) |
Fix T101098: Moving meta strip can change its length
Caused by clamping handle translation to strip bounds in functions
`SEQ_time_*_handle_frame_set()` to prevent strip ending in invalid
state. Issue happens when meta strip is moved so quickly, such that
immediate offset is greater than strip length.
Currently meta strip bounds are updated when any contained strip changes
its position, but this update always preserves meta strip position.
Transforming meta strip is not possible directly and all contained
strips are moved instead. Therefore this is 2-step process and fix needs
to be applied on update function and on translation function.
Inline offset handling without clamping in function
`SEQ_time_update_meta_strip_range()`.
Add new function `seq_time_translate_handles()` to move both handles at
once in `SEQ_transform_translate_sequence()`.
Diffstat (limited to 'source/blender/sequencer')
-rw-r--r-- | source/blender/sequencer/intern/strip_time.c | 24 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_time.h | 1 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_transform.c | 5 |
3 files changed, 22 insertions, 8 deletions
diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c index 5d8266dbc6e..6725e0a8394 100644 --- a/source/blender/sequencer/intern/strip_time.c +++ b/source/blender/sequencer/intern/strip_time.c @@ -169,11 +169,16 @@ void SEQ_time_update_meta_strip_range(const Scene *scene, Sequence *seq_meta) seq_meta->len -= seq_meta->anim_startofs; seq_meta->len -= seq_meta->anim_endofs; - seq_update_sound_bounds_recursive(scene, seq_meta); + /* Functions `SEQ_time_*_handle_frame_set()` can not be used here, because they are clamped, so + * change must be done at once. */ + seq_meta->startofs = strip_start - seq_meta->start; + seq_meta->startdisp = strip_start; /* Only to make files usable in older versions. */ + seq_meta->endofs = seq_meta->start + SEQ_time_strip_length_get(scene, seq_meta) - strip_end; + seq_meta->enddisp = strip_end; /* Only to make files usable in older versions. */ - /* Prevent meta-strip to move in timeline. */ - SEQ_time_left_handle_frame_set(scene, seq_meta, strip_start); - SEQ_time_right_handle_frame_set(scene, seq_meta, strip_end); + seq_update_sound_bounds_recursive(scene, seq_meta); + SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq_meta)); + seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq_meta)); } void seq_time_effect_range_set(const Scene *scene, Sequence *seq) @@ -546,3 +551,14 @@ void SEQ_time_right_handle_frame_set(const Scene *scene, Sequence *seq, int val) SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq)); seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq)); } + +void seq_time_translate_handles(const Scene *scene, Sequence *seq, const int offset) +{ + seq->startofs += offset; + seq->endofs -= offset; + seq->startdisp += offset; /* Only to make files usable in older versions. */ + seq->enddisp -= offset; /* Only to make files usable in older versions. */ + + SEQ_time_update_meta_strip_range(scene, seq_sequence_lookup_meta_by_seq(scene, seq)); + seq_time_update_effects_strip_range(scene, seq_sequence_lookup_effects_by_seq(scene, seq)); +} diff --git a/source/blender/sequencer/intern/strip_time.h b/source/blender/sequencer/intern/strip_time.h index db581649f8a..19f549924df 100644 --- a/source/blender/sequencer/intern/strip_time.h +++ b/source/blender/sequencer/intern/strip_time.h @@ -40,6 +40,7 @@ void seq_time_gap_info_get(const struct Scene *scene, struct GapInfo *r_gap_info); void seq_time_effect_range_set(const struct Scene *scene, Sequence *seq); void seq_time_update_effects_strip_range(const struct Scene *scene, struct SeqCollection *effects); +void seq_time_translate_handles(const struct Scene *scene, struct Sequence *seq, const int offset); #ifdef __cplusplus } diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index 68b30c9ce19..447ab9c221d 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -146,10 +146,7 @@ void SEQ_transform_translate_sequence(Scene *evil_scene, Sequence *seq, int delt SEQ_transform_translate_sequence(evil_scene, seq_child, delta); } /* Move meta start/end points. */ - SEQ_time_left_handle_frame_set( - evil_scene, seq, SEQ_time_left_handle_frame_get(evil_scene, seq) + delta); - SEQ_time_right_handle_frame_set( - evil_scene, seq, SEQ_time_right_handle_frame_get(evil_scene, seq) + delta); + seq_time_translate_handles(evil_scene, seq, delta); } else { /* All other strip types. */ seq->start += delta; |