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/sculpt_paint/paint_image.c | 4 ++-- source/blender/editors/sculpt_paint/paint_ops.c | 4 ++-- source/blender/editors/sculpt_paint/sculpt.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 9c41989fcd4..4d4af028570 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -808,10 +808,10 @@ void ED_space_image_paint_update(Main *bmain, wmWindowManager *wm, Scene *scene) ImagePaintSettings *imapaint = &settings->imapaint; bool enabled = false; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_IMAGE) { if (((SpaceImage *)area->spacedata.first)->mode == SI_MODE_PAINT) { enabled = true; diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index cc848b80bb3..d607b6a9d6f 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -397,7 +397,7 @@ static int palette_sort_exec(bContext *C, wmOperator *op) color_array = MEM_calloc_arrayN(totcol, sizeof(tPaletteColorHSV), __func__); /* Put all colors in an array. */ int t = 0; - for (PaletteColor *color = palette->colors.first; color; color = color->next) { + LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) { float h, s, v; rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &v); col_elm = &color_array[t]; @@ -543,7 +543,7 @@ static int palette_join_exec(bContext *C, wmOperator *op) const int totcol = BLI_listbase_count(&palette_join->colors); if (totcol > 0) { - for (PaletteColor *color = palette_join->colors.first; color; color = color->next) { + LISTBASE_FOREACH (PaletteColor *, color, &palette_join->colors) { PaletteColor *palcol = BKE_palette_color_add(palette); if (palcol) { copy_v3_v3(palcol->rgb, color->rgb); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a981e722b1c..2b5d576f7c2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7821,9 +7821,9 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate rv3d->rflag &= ~RV3D_PAINTING; } - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { bScreen *screen = WM_window_get_active_screen(win); - for (ScrArea *area = screen->areabase.first; area; area = area->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { SpaceLink *sl = area->spacedata.first; if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; @@ -7834,7 +7834,7 @@ static void sculpt_flush_update_done(const bContext *C, Object *ob, SculptUpdate /* Tag all 3D viewports for redraw now that we are done. Others * viewports did not get a full redraw, and anti-aliasing for the * current viewport was deactivated. */ - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_WINDOW) { ED_region_tag_redraw(region); } -- cgit v1.2.3