From 11b50b2b77664f820291acb029c394a36edb337d Mon Sep 17 00:00:00 2001 From: Richard Antalik Date: Thu, 6 May 2021 05:53:17 +0200 Subject: Cleanup: VSE: move functions from incorrect file `SEQ_recursive_apply` and `SEQ_seqbase_recursive_apply` were incorrectly refactored into `iterator.c` file, but they aren't part and don't use sequencer iterator. Functions are moved to `utils.c` file. --- source/blender/blenloader/intern/readfile.c | 3 ++- source/blender/editors/sound/sound_ops.c | 3 ++- .../editors/space_sequencer/sequencer_edit.c | 4 +-- source/blender/makesrna/intern/rna_sequencer.c | 10 ++++---- source/blender/sequencer/SEQ_iterator.h | 6 ----- source/blender/sequencer/SEQ_utils.h | 7 ++++- source/blender/sequencer/intern/iterator.c | 28 -------------------- source/blender/sequencer/intern/utils.c | 30 +++++++++++++++++++++- 8 files changed, 46 insertions(+), 45 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 24501adcb90..fe7d50bfa15 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -111,6 +111,7 @@ #include "SEQ_iterator.h" #include "SEQ_modifier.h" #include "SEQ_sequencer.h" +#include "SEQ_utils.h" #include "readfile.h" @@ -2696,7 +2697,7 @@ static int lib_link_seq_clipboard_cb(Sequence *seq, void *arg_pt) static void lib_link_clipboard_restore(struct IDNameLib_Map *id_map) { /* update IDs stored in sequencer clipboard */ - SEQ_iterator_seqbase_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map); + SEQ_seqbase_recursive_apply(&seqbase_clipboard, lib_link_seq_clipboard_cb, id_map); } static int lib_link_main_data_restore_cb(LibraryIDLinkCallbackData *cb_data) diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 85616f6356d..fe0a53ae964 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -52,6 +52,7 @@ #include "RNA_enum_types.h" #include "SEQ_iterator.h" +#include "SEQ_utils.h" #include "UI_interface.h" @@ -258,7 +259,7 @@ static void sound_update_animation_flags(Scene *scene) scene->id.tag |= LIB_TAG_DOIT; SEQ_ALL_BEGIN (scene->ed, seq) { - SEQ_iterator_recursive_apply(seq, sound_update_animation_flags_fn, scene); + SEQ_recursive_apply(seq, sound_update_animation_flags_fn, scene); } SEQ_ALL_END; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 7279fdd2da2..9c204373ffc 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1608,7 +1608,7 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) BLI_movelisttolist(ed->seqbasep, &nseqbase); for (; seq; seq = seq->next) { - SEQ_iterator_recursive_apply(seq, apply_unique_name_fn, scene); + SEQ_recursive_apply(seq, apply_unique_name_fn, scene); } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2465,7 +2465,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *op) for (iseq = iseq_first; iseq; iseq = iseq->next) { /* Make sure, that pasted strips have unique names. */ - SEQ_iterator_recursive_apply(iseq, apply_unique_name_fn, scene); + SEQ_recursive_apply(iseq, apply_unique_name_fn, scene); /* Translate after name has been changed, otherwise this will affect animdata of original * strip. */ SEQ_transform_translate_sequence(scene, iseq, ofs); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index f411566b623..b2e399d41f5 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -505,7 +505,7 @@ static Sequence *sequence_get_by_transform(Editing *ed, StripTransform *transfor data.data = transform; /* irritating we need to search for our sequence! */ - SEQ_iterator_seqbase_recursive_apply(&ed->seqbase, transform_seq_cmp_fn, &data); + SEQ_seqbase_recursive_apply(&ed->seqbase, transform_seq_cmp_fn, &data); return data.seq; } @@ -557,7 +557,7 @@ static Sequence *sequence_get_by_crop(Editing *ed, StripCrop *crop) data.data = crop; /* irritating we need to search for our sequence! */ - SEQ_iterator_seqbase_recursive_apply(&ed->seqbase, crop_seq_cmp_fn, &data); + SEQ_seqbase_recursive_apply(&ed->seqbase, crop_seq_cmp_fn, &data); return data.seq; } @@ -951,7 +951,7 @@ static Sequence *sequence_get_by_proxy(Editing *ed, StripProxy *proxy) data.seq = NULL; data.data = proxy; - SEQ_iterator_seqbase_recursive_apply(&ed->seqbase, seqproxy_seq_cmp_fn, &data); + SEQ_seqbase_recursive_apply(&ed->seqbase, seqproxy_seq_cmp_fn, &data); return data.seq; } @@ -1016,7 +1016,7 @@ static Sequence *sequence_get_by_colorbalance(Editing *ed, data.data = cb; /* irritating we need to search for our sequence! */ - SEQ_iterator_seqbase_recursive_apply(&ed->seqbase, colbalance_seq_cmp_fn, &data); + SEQ_seqbase_recursive_apply(&ed->seqbase, colbalance_seq_cmp_fn, &data); *r_smd = data.smd; @@ -1140,7 +1140,7 @@ static Sequence *sequence_get_by_modifier(Editing *ed, SequenceModifierData *smd data.data = smd; /* irritating we need to search for our sequence! */ - SEQ_iterator_seqbase_recursive_apply(&ed->seqbase, modifier_seq_cmp_fn, &data); + SEQ_seqbase_recursive_apply(&ed->seqbase, modifier_seq_cmp_fn, &data); return data.seq; } diff --git a/source/blender/sequencer/SEQ_iterator.h b/source/blender/sequencer/SEQ_iterator.h index 669c55e1f4c..b34f0558c56 100644 --- a/source/blender/sequencer/SEQ_iterator.h +++ b/source/blender/sequencer/SEQ_iterator.h @@ -54,12 +54,6 @@ typedef struct SeqIterator { void SEQ_iterator_begin(struct Editing *ed, SeqIterator *iter, const bool use_current_sequences); void SEQ_iterator_next(SeqIterator *iter); void SEQ_iterator_end(SeqIterator *iter); -int SEQ_iterator_seqbase_recursive_apply(struct ListBase *seqbase, - int (*apply_fn)(struct Sequence *seq, void *), - void *arg); -int SEQ_iterator_recursive_apply(struct Sequence *seq, - int (*apply_fn)(struct Sequence *, void *), - void *arg); #ifdef __cplusplus } diff --git a/source/blender/sequencer/SEQ_utils.h b/source/blender/sequencer/SEQ_utils.h index 45f53a64688..52fac5d7d0e 100644 --- a/source/blender/sequencer/SEQ_utils.h +++ b/source/blender/sequencer/SEQ_utils.h @@ -54,7 +54,12 @@ void SEQ_set_scale_to_fit(const struct Sequence *seq, const int preview_width, const int preview_height, const eSeqImageFitMethod fit_method); - +int SEQ_seqbase_recursive_apply(struct ListBase *seqbase, + int (*apply_fn)(struct Sequence *seq, void *), + void *arg); +int SEQ_recursive_apply(struct Sequence *seq, + int (*apply_fn)(struct Sequence *, void *), + void *arg); #ifdef __cplusplus } #endif diff --git a/source/blender/sequencer/intern/iterator.c b/source/blender/sequencer/intern/iterator.c index f99667dea04..356f5db45e8 100644 --- a/source/blender/sequencer/intern/iterator.c +++ b/source/blender/sequencer/intern/iterator.c @@ -138,31 +138,3 @@ void SEQ_iterator_end(SeqIterator *iter) iter->valid = 0; } - -int SEQ_iterator_seqbase_recursive_apply(ListBase *seqbase, - int (*apply_fn)(Sequence *seq, void *), - void *arg) -{ - Sequence *iseq; - for (iseq = seqbase->first; iseq; iseq = iseq->next) { - if (SEQ_iterator_recursive_apply(iseq, apply_fn, arg) == -1) { - return -1; /* bail out */ - } - } - return 1; -} - -int SEQ_iterator_recursive_apply(Sequence *seq, int (*apply_fn)(Sequence *, void *), void *arg) -{ - int ret = apply_fn(seq, arg); - - if (ret == -1) { - return -1; /* bail out */ - } - - if (ret && seq->seqbase.first) { - ret = SEQ_iterator_seqbase_recursive_apply(&seq->seqbase, apply_fn, arg); - } - - return ret; -} diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index a15465eb3c0..6d5332b2b15 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -160,7 +160,7 @@ void SEQ_sequence_base_unique_name_recursive(ListBase *seqbasep, Sequence *seq) while (sui.match) { sui.match = 0; seqbase_unique_name(seqbasep, &sui); - SEQ_iterator_seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_fn, &sui); + SEQ_seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_fn, &sui); } BLI_strncpy(seq->name + 2, sui.name_dest, sizeof(seq->name) - 2); @@ -584,3 +584,31 @@ void SEQ_set_scale_to_fit(const Sequence *seq, break; } } + +int SEQ_seqbase_recursive_apply(ListBase *seqbase, + int (*apply_fn)(Sequence *seq, void *), + void *arg) +{ + Sequence *iseq; + for (iseq = seqbase->first; iseq; iseq = iseq->next) { + if (SEQ_recursive_apply(iseq, apply_fn, arg) == -1) { + return -1; /* bail out */ + } + } + return 1; +} + +int SEQ_recursive_apply(Sequence *seq, int (*apply_fn)(Sequence *, void *), void *arg) +{ + int ret = apply_fn(seq, arg); + + if (ret == -1) { + return -1; /* bail out */ + } + + if (ret && seq->seqbase.first) { + ret = SEQ_seqbase_recursive_apply(&seq->seqbase, apply_fn, arg); + } + + return ret; +} -- cgit v1.2.3