From d138cbfb47e379edc1ee915a8c6ff65b01f000d6 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Fri, 3 Apr 2020 19:15:01 +0200 Subject: Code Quality: Replace for loops with LISTBASE_FOREACH Note this only changes cases where the variable was declared inside the for loop. To handle it outside as well is a different challenge. Differential Revision: https://developer.blender.org/D7320 --- source/blender/editors/space_nla/nla_channels.c | 2 +- source/blender/editors/space_nla/nla_draw.c | 8 ++++---- source/blender/editors/space_nla/nla_select.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/editors/space_nla') diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index d08d39700d6..5adcec8a5d7 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -146,7 +146,7 @@ static int mouse_nla_channels( else { /* deselect all */ /* TODO: should this deselect all other types of channels too? */ - for (Base *b = view_layer->object_bases.first; b; b = b->next) { + LISTBASE_FOREACH (Base *, b, &view_layer->object_bases) { ED_object_base_select(b, BA_DESELECT); if (b->object->adt) { b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 5a59ba6b553..5c4ccd96534 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -150,7 +150,7 @@ static void nla_action_draw_keyframes( /* - disregard the selection status of keyframes so they draw a certain way * - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction */ - for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) { + LISTBASE_FOREACH (ActKeyColumn *, ak, &keys) { draw_keyframe_shape(ak->cfra, y, 6.0f, @@ -207,7 +207,7 @@ static void nla_actionclip_draw_markers( immUniformThemeColorShade(TH_STRIP_SELECT, shade); immBeginAtMost(GPU_PRIM_LINES, BLI_listbase_count(&act->markers) * 2); - for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) { + LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) { if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) { float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP); @@ -238,7 +238,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) /* just a solid color, so that it is very easy to spot */ int shade = 20; /* draw the markers in the first level of strips only (if they are actions) */ - for (NlaStrip *nls = strip->strips.first; nls; nls = nls->next) { + LISTBASE_FOREACH (NlaStrip *, nls, &strip->strips) { if (nls->type == NLASTRIP_TYPE_CLIP) { nla_actionclip_draw_markers(nls, yminc, ymaxc, shade, false); } @@ -565,7 +565,7 @@ static void nla_draw_strip(SpaceNla *snla, immBeginAtMost(GPU_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips)); /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ - for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) { + LISTBASE_FOREACH (NlaStrip *, cs, &strip->strips) { /* draw start-line if not same as end of previous (and only if not the first strip) * - on upper half of strip */ diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 09abfc300c7..ec41368b9f0 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -308,7 +308,7 @@ static void nlaedit_strip_at_region_position( if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; - for (NlaStrip *strip = nlt->strips.first; strip; strip = strip->next) { + LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) { *r_ale = ale; *r_strip = strip; -- cgit v1.2.3