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/screen/workspace_edit.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/screen/workspace_edit.c') diff --git a/source/blender/editors/screen/workspace_edit.c b/source/blender/editors/screen/workspace_edit.c index 784fa60999d..8feef0c675a 100644 --- a/source/blender/editors/screen/workspace_edit.c +++ b/source/blender/editors/screen/workspace_edit.c @@ -198,8 +198,7 @@ WorkSpace *ED_workspace_duplicate(WorkSpace *workspace_old, Main *bmain, wmWindo /* TODO(campbell): tools */ - for (WorkSpaceLayout *layout_old = layouts_old->first; layout_old; - layout_old = layout_old->next) { + LISTBASE_FOREACH (WorkSpaceLayout *, layout_old, layouts_old) { WorkSpaceLayout *layout_new = ED_workspace_layout_duplicate( bmain, workspace_new, layout_old, win); @@ -222,7 +221,7 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo ListBase ordered; BKE_id_ordered_list(&ordered, &bmain->workspaces); WorkSpace *prev = NULL, *next = NULL; - for (LinkData *link = ordered.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &ordered) { if (link->data == workspace) { prev = link->prev ? link->prev->data : NULL; next = link->next ? link->next->data : NULL; @@ -232,7 +231,7 @@ bool ED_workspace_delete(WorkSpace *workspace, Main *bmain, bContext *C, wmWindo BLI_freelistN(&ordered); BLI_assert((prev != NULL) || (next != NULL)); - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { WorkSpace *workspace_active = WM_window_get_active_workspace(win); if (workspace_active == workspace) { ED_workspace_change((prev != NULL) ? prev : next, C, wm, win); @@ -481,7 +480,7 @@ static int workspace_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS ListBase templates; BKE_appdir_app_templates(&templates); - for (LinkData *link = templates.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &templates) { char *template = link->data; char display_name[FILE_MAX]; -- cgit v1.2.3