Fix incorrect assumption when handling overlap

In `shuffle_seq_time_offset_get()` code tried to check whether
`strips_to_shuffle` would overlap with each other, but this was done
incorrectly. This check relied on result of `shuffle_seq_test_overlap()`
but that function assumes, that only 1 strip of its input is transformed
by `offset`. This means, that if 2 strips are moved by same offset and
overlap is checked against each other it could result in true return
value. However this is checked in the code already by
`strips_to_shuffle.contains(seq_other)`, in which case loop continues.
This resulted in emmision of warning which was incorrect.

The issue is fixed by continuing loop if `strips_to_shuffle` contains
`seq_other` as first precondition to signify, that this is expected and
in fact inevitable case. `shuffle_seq_test_overlap()` does not check
whether 2 passed strips are equal, rather `BLI_assert` is used to
signify, that this is not valid use-case.

Since the warning can not happen, the logging was removed.
This commit is contained in:
Richard Antalik
2023-11-07 04:54:55 +01:00
parent 570799374f
commit 9463135fed
@@ -36,8 +36,6 @@
#include "CLG_log.h"
static CLG_LogRef LOG = {"seq.strip_transform"};
bool SEQ_transform_single_image_check(Sequence *seq)
{
return (seq->flag & SEQ_SINGLE_FRAME_CONTENT) != 0;
@@ -195,7 +193,8 @@ static bool shuffle_seq_test_overlap(const Scene *scene,
const Sequence *seq2,
const int offset)
{
return (seq1 != seq2 && seq1->machine == seq2->machine &&
BLI_assert(seq1 != seq2);
return (seq1->machine == seq2->machine &&
((SEQ_time_right_handle_frame_get(scene, seq1) + offset <=
SEQ_time_left_handle_frame_get(scene, seq2)) ||
(SEQ_time_left_handle_frame_get(scene, seq1) + offset >=
@@ -214,16 +213,13 @@ static int shuffle_seq_time_offset_get(const Scene *scene,
all_conflicts_resolved = true;
for (Sequence *seq : strips_to_shuffle) {
LISTBASE_FOREACH (Sequence *, seq_other, seqbasep) {
if (!shuffle_seq_test_overlap(scene, seq, seq_other, offset)) {
if (strips_to_shuffle.contains(seq_other)) {
continue;
}
if (SEQ_relation_is_effect_of_strip(seq_other, seq)) {
continue;
}
if (UNLIKELY(strips_to_shuffle.contains(seq_other))) {
CLOG_WARN(&LOG,
"Strip overlaps with itself or another strip, that is to be shuffled. "
"This should never happen.");
if (!shuffle_seq_test_overlap(scene, seq, seq_other, offset)) {
continue;
}