From aefa6261c324b8117c25041c285b6cb1eaab31f8 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 17 Feb 2013 21:44:13 +0000 Subject: == Sequencer == This fixes a bug in sequencer cut tool: * if you cut two strips of the same name class (MVI_XXXX.MOV and MVI_XXXX.001) the two new generated strips will end up with the same name. (easy test case: add a MOV file with it's accompanying audio track to the timeline and then cut both strips at once into two pieces) * visible problem: your animation data will get messed up on the way, since the animation system doesn't know, which strip it should assign the animation. Problem was caused by generating a new list of sequences within the cut_seq_list() function: Since dupli_seq() can't see the members of the new list of sequences, it won't be able to assign unique names in all cases. --- .../editors/space_sequencer/sequencer_edit.c | 48 ++++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'source/blender/editors/space_sequencer') diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 97943f7e6ac..cec9373ebd7 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -817,40 +817,56 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe) /* like duplicate, but only duplicate and cut overlapping strips, - * strips to the left of the cutframe are ignored and strips to the right are moved into the new list */ -static int cut_seq_list(Scene *scene, ListBase *old, ListBase *new, int cutframe, + * strips to the left of the cutframe are ignored and strips to the right + * are moved to the end of slist + * we have to work on the same slist (not using a seperate list), since + * otherwise dupli_seq can't check for duplicate names properly and + * may generate strips with the same name (which will mess up animdata) + */ + +static int cut_seq_list(Scene *scene, ListBase *slist, int cutframe, Sequence * (*cut_seq)(Scene *, Sequence *, int)) { int did_something = FALSE; Sequence *seq, *seq_next_iter; - seq = old->first; + for (seq = slist->first; seq; seq = seq->next) { + seq->tmp = NULL; + } - while (seq) { + seq = slist->first; + + while (seq && !seq->tmp) { seq_next_iter = seq->next; /* we need this because we may remove seq */ - - seq->tmp = NULL; + /* only handle strips not marked as new */ if (seq->flag & SELECT) { if (cutframe > seq->startdisp && cutframe < seq->enddisp) { Sequence *seqn = cut_seq(scene, seq, cutframe); if (seqn) { - BLI_addtail(new, seqn); + BLI_addtail(slist, seqn); + seqn->tmp = seq; /* mark as new */ + did_something = TRUE; } - did_something = TRUE; } else if (seq->enddisp <= cutframe) { /* do nothing */ } else if (seq->startdisp >= cutframe) { - /* move into new list */ - BLI_remlink(old, seq); - BLI_addtail(new, seq); + /* move to tail and mark as new */ + BLI_remlink(slist, seq); + BLI_addtail(slist, seq); + seq->tmp = seq; } } seq = seq_next_iter; } + + for (; seq; seq = seq->next) { + seq->tmp = NULL; + } + return did_something; } @@ -1488,25 +1504,21 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int cut_side, cut_hard, cut_frame; - ListBase newlist; int changed; cut_frame = RNA_int_get(op->ptr, "frame"); cut_hard = RNA_enum_get(op->ptr, "type"); cut_side = RNA_enum_get(op->ptr, "side"); - newlist.first = newlist.last = NULL; - if (cut_hard == SEQ_CUT_HARD) { - changed = cut_seq_list(scene, ed->seqbasep, &newlist, cut_frame, cut_seq_hard); + changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_hard); } else { - changed = cut_seq_list(scene, ed->seqbasep, &newlist, cut_frame, cut_seq_soft); + changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_soft); } - if (newlist.first) { /* got new strips ? */ + if (changed) { /* got new strips ? */ Sequence *seq; - BLI_movelisttolist(ed->seqbasep, &newlist); if (cut_side != SEQ_SIDE_BOTH) { SEQP_BEGIN (ed, seq) -- cgit v1.2.3