Cleanup: Remove SEQ_CURRENT_BEGIN macro

Use LISTBASE_FOREACH instead.
SEQ_CURRENT_BEGIN did null checks, so now these must be explicit.

Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D10823
This commit is contained in:
Richard Antalik 2021-03-31 09:27:31 +02:00
parent 43369ca80e
commit b128ffd539
8 changed files with 27 additions and 77 deletions

@ -255,7 +255,6 @@ ForEachMacros:
- SCULPT_VERTEX_DUPLICATES_AND_NEIGHBORS_ITER_BEGIN
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN
- SEQ_ALL_BEGIN
- SEQ_CURRENT_BEGIN
- SURFACE_QUAD_ITER_BEGIN
- foreach
- ED_screen_areas_iter

@ -81,6 +81,7 @@
#include "BKE_pointcache.h"
#include "SEQ_iterator.h"
#include "SEQ_sequencer.h"
#include "NOD_socket.h"
@ -2560,18 +2561,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain)
if (bmain->versionfile < 249 && bmain->subversionfile < 2) {
Scene *sce = bmain->scenes.first;
Sequence *seq;
Editing *ed;
while (sce) {
ed = sce->ed;
if (ed) {
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (seq->strip && seq->strip->proxy) {
seq->strip->proxy->quality = 90;
}
}
SEQ_CURRENT_END;
}
sce = sce->id.next;

@ -105,8 +105,6 @@
* it messes up transform. */
#undef SEQ_ALL_BEGIN
#undef SEQ_ALL_END
#undef SEQ_CURRENT_BEGIN
#undef SEQ_CURRENT_END
static Sequence *special_seq_update = NULL;

@ -312,8 +312,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op)
}
}
/* Test for effects and overlap.
* Don't use SEQ_CURRENT_BEGIN since that would be recursive. */
/* Test for effects and overlap. */
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT && !(seq->depth == 0 && seq->flag & SEQ_LOCK)) {
seq->flag &= ~SEQ_OVERLAP;
@ -1411,28 +1410,25 @@ static int sequencer_split_exec(bContext *C, wmOperator *op)
}
if (changed) { /* Got new strips? */
Sequence *seq;
if (ignore_selection) {
if (use_cursor_position) {
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (seq->enddisp == split_frame && seq->machine == split_channel) {
seq_selected = seq->flag & SEQ_ALLSEL;
}
}
SEQ_CURRENT_END;
if (!seq_selected) {
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (seq->startdisp == split_frame && seq->machine == split_channel) {
seq->flag &= ~SEQ_ALLSEL;
}
}
SEQ_CURRENT_END;
}
}
}
else {
if (split_side != SEQ_SIDE_BOTH) {
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (split_side == SEQ_SIDE_LEFT) {
if (seq->startdisp >= split_frame) {
seq->flag &= ~SEQ_ALLSEL;
@ -1444,7 +1440,6 @@ static int sequencer_split_exec(bContext *C, wmOperator *op)
}
}
}
SEQ_CURRENT_END;
}
}
@ -1652,16 +1647,14 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op))
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = SEQ_editing_get(scene, false);
Sequence *seq;
SEQ_prefetch_stop(scene);
SEQ_CURRENT_BEGIN (scene->ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (seq->flag & SELECT) {
SEQ_edit_flag_for_removal(scene, ed->seqbasep, seq);
}
}
SEQ_CURRENT_END;
SEQ_edit_remove_flagged_sequences(scene, ed->seqbasep);
DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
@ -2418,17 +2411,15 @@ void SEQUENCER_OT_copy(wmOperatorType *ot)
void ED_sequencer_deselect_all(Scene *scene)
{
Sequence *seq;
Editing *ed = SEQ_editing_get(scene, false);
if (ed == NULL) {
return;
}
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
seq->flag &= ~SEQ_ALLSEL;
}
SEQ_CURRENT_END;
}
static int sequencer_paste_exec(bContext *C, wmOperator *op)

@ -237,7 +237,7 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
SEQ_CURRENT_BEGIN (ed, seq_iter) {
LISTBASE_FOREACH (Sequence *, seq_iter, SEQ_active_seqbase_get(ed)) {
if (seq_iter->flag & SELECT) {
if (seq_iter == seq) {
continue;
@ -259,7 +259,6 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op)
SEQ_modifier_list_copy(seq_iter, seq);
}
}
SEQ_CURRENT_END;
SEQ_relations_invalidate_cache_preprocessed(scene, seq);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);

@ -58,7 +58,6 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
Scene *scene = CTX_data_scene(C);
Editing *ed = SEQ_editing_get(scene, false);
ScrArea *area = CTX_wm_area(C);
Sequence *seq;
if (ed == NULL) {
return;
@ -70,7 +69,7 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
GSet *file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
bool selected = false; /* Check for no selected strips */
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE) || (seq->flag & SELECT) == 0) {
continue;
}
@ -92,7 +91,6 @@ static void seq_proxy_build_job(const bContext *C, ReportList *reports)
BKE_reportf(reports, RPT_WARNING, "Overwrite is not checked for %s, skipping", seq->name);
}
}
SEQ_CURRENT_END;
BLI_gset_free(file_list, MEM_freeN);
@ -124,7 +122,6 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = SEQ_editing_get(scene, false);
Sequence *seq;
GSet *file_list;
if (ed == NULL) {
@ -133,7 +130,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list");
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if ((seq->flag & SELECT)) {
ListBase queue = {NULL, NULL};
LinkData *link;
@ -150,7 +147,6 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
SEQ_relations_free_imbuf(scene, &ed->seqbase, false);
}
}
SEQ_CURRENT_END;
BLI_gset_free(file_list, MEM_freeN);
@ -189,7 +185,6 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = SEQ_editing_get(scene, false);
Sequence *seq;
bool proxy_25 = RNA_boolean_get(op->ptr, "proxy_25");
bool proxy_50 = RNA_boolean_get(op->ptr, "proxy_50");
bool proxy_75 = RNA_boolean_get(op->ptr, "proxy_75");
@ -201,7 +196,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
turnon = false;
}
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if ((seq->flag & SELECT)) {
if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) {
SEQ_proxy_set(seq, turnon);
@ -246,7 +241,6 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op)
}
}
}
SEQ_CURRENT_END;
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);

@ -548,14 +548,13 @@ static int sequencer_select_exec(bContext *C, wmOperator *op)
const float x = UI_view2d_region_to_view_x(v2d, mval[0]);
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (((x < CFRA) && (seq->enddisp <= CFRA)) || ((x >= CFRA) && (seq->startdisp >= CFRA))) {
/* Select left or right. */
seq->flag |= SELECT;
recurs_sel_seq(seq);
}
}
SEQ_CURRENT_END;
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
@ -1170,7 +1169,6 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
Editing *ed = SEQ_editing_get(scene, false);
const bool extend = RNA_boolean_get(op->ptr, "extend");
const int side = RNA_enum_get(op->ptr, "side");
Sequence *seq;
if (ed == NULL) {
return OPERATOR_CANCELLED;
@ -1179,7 +1177,7 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
ED_sequencer_deselect_all(scene);
}
const int timeline_frame = CFRA;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
bool test = false;
switch (side) {
case -1:
@ -1198,7 +1196,6 @@ static int sequencer_select_side_of_frame_exec(bContext *C, wmOperator *op)
recurs_sel_seq(seq);
}
}
SEQ_CURRENT_END;
ED_outliner_select_sync_from_sequence_tag(C);
@ -1483,58 +1480,51 @@ static const EnumPropertyItem sequencer_prop_select_grouped_types[] = {
static bool select_grouped_type(Editing *ed, Sequence *actseq, const int channel)
{
Sequence *seq;
bool changed = false;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == actseq->type) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
return changed;
}
static bool select_grouped_type_basic(Editing *ed, Sequence *actseq, const int channel)
{
Sequence *seq;
bool changed = false;
const bool is_sound = SEQ_IS_SOUND(actseq);
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && (is_sound ? SEQ_IS_SOUND(seq) : !SEQ_IS_SOUND(seq))) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
return changed;
}
static bool select_grouped_type_effect(Editing *ed, Sequence *actseq, const int channel)
{
Sequence *seq;
bool changed = false;
const bool is_effect = SEQ_IS_EFFECT(actseq);
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) &&
(is_effect ? SEQ_IS_EFFECT(seq) : !SEQ_IS_EFFECT(seq))) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
return changed;
}
static bool select_grouped_data(Editing *ed, Sequence *actseq, const int channel)
{
Sequence *seq;
bool changed = false;
const char *dir = actseq->strip ? actseq->strip->dir : NULL;
@ -1543,45 +1533,41 @@ static bool select_grouped_data(Editing *ed, Sequence *actseq, const int channel
}
if (SEQ_HAS_PATH(actseq) && dir) {
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && SEQ_HAS_PATH(seq) && seq->strip &&
STREQ(seq->strip->dir, dir)) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
}
else if (actseq->type == SEQ_TYPE_SCENE) {
Scene *sce = actseq->scene;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_SCENE && seq->scene == sce) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
}
else if (actseq->type == SEQ_TYPE_MOVIECLIP) {
MovieClip *clip = actseq->clip;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MOVIECLIP &&
seq->clip == clip) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
}
else if (actseq->type == SEQ_TYPE_MASK) {
struct Mask *mask = actseq->mask;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && seq->type == SEQ_TYPE_MASK && seq->mask == mask) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
}
return changed;
@ -1589,7 +1575,6 @@ static bool select_grouped_data(Editing *ed, Sequence *actseq, const int channel
static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int channel)
{
Sequence *seq;
bool changed = false;
bool effects[SEQ_TYPE_MAX + 1];
@ -1597,15 +1582,14 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann
effects[i] = false;
}
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && (seq->type & SEQ_TYPE_EFFECT) &&
ELEM(actseq, seq->seq1, seq->seq2, seq->seq3)) {
effects[seq->type] = true;
}
}
SEQ_CURRENT_END;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (SEQ_CHANNEL_CHECK(seq, channel) && effects[seq->type]) {
if (seq->seq1) {
seq->seq1->flag |= SELECT;
@ -1619,23 +1603,20 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann
changed = true;
}
}
SEQ_CURRENT_END;
return changed;
}
static bool select_grouped_time_overlap(Editing *ed, Sequence *actseq)
{
Sequence *seq;
bool changed = false;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
if (seq->startdisp < actseq->enddisp && seq->enddisp > actseq->startdisp) {
seq->flag |= SELECT;
changed = true;
}
}
SEQ_CURRENT_END;
return changed;
}
@ -1650,10 +1631,9 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int
int machine = actseq->machine;
SeqIterator iter;
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
seq->tmp = NULL;
}
SEQ_CURRENT_END;
actseq->tmp = POINTER_FROM_INT(true);
@ -1711,7 +1691,7 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Editing *ed = SEQ_editing_get(scene, false);
Sequence *seq, *actseq = SEQ_select_active_get(scene);
Sequence *actseq = SEQ_select_active_get(scene);
if (actseq == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active sequence!");
@ -1725,11 +1705,10 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op)
bool changed = false;
if (!extend) {
SEQ_CURRENT_BEGIN (ed, seq) {
LISTBASE_FOREACH (Sequence *, seq, SEQ_active_seqbase_get(ed)) {
seq->flag &= ~SELECT;
changed = true;
}
SEQ_CURRENT_END;
}
switch (type) {

@ -51,15 +51,6 @@ typedef struct SeqIterator {
} \
((void)0)
#define SEQ_CURRENT_BEGIN(_ed, _seq) \
{ \
SeqIterator iter_macro; \
for (SEQ_iterator_begin(_ed, &iter_macro, true); iter_macro.valid; \
SEQ_iterator_next(&iter_macro)) { \
_seq = iter_macro.seq;
#define SEQ_CURRENT_END SEQ_ALL_END
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);