diff options
author | Dalai Felinto <dalai@blender.org> | 2020-04-03 20:15:01 +0300 |
---|---|---|
committer | Dalai Felinto <dalai@blender.org> | 2020-04-03 20:27:46 +0300 |
commit | d138cbfb47e379edc1ee915a8c6ff65b01f000d6 (patch) | |
tree | f4773ecce897c32eaf75295dd5f6a8e730d471ed /source/blender/editors/interface | |
parent | b0c1184875d39abac4a65a5d20e263ea6d841009 (diff) |
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
Diffstat (limited to 'source/blender/editors/interface')
13 files changed, 51 insertions, 52 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 11dc8b3b8b4..339124db355 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -261,7 +261,7 @@ void ui_region_to_window(const ARegion *region, int *x, int *y) static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) { int sepr_flex_len = 0; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->type == UI_BTYPE_SEPR_SPACER) { sepr_flex_len++; } @@ -283,7 +283,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) /* We could get rid of this loop if we agree on a max number of spacer */ int *spacers_pos = alloca(sizeof(*spacers_pos) * (size_t)sepr_flex_len); int i = 0; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->type == UI_BTYPE_SEPR_SPACER) { ui_but_to_pixelrect(&rect, region, block, but); spacers_pos[i] = rect.xmax + UI_HEADER_OFFSET; @@ -294,7 +294,7 @@ static void ui_update_flexible_spacing(const ARegion *region, uiBlock *block) const float segment_width = region_width / (float)sepr_flex_len; float offset = 0, remaining_space = region_width - buttons_width; i = 0; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { BLI_rctf_translate(&but->rect, offset, 0); if (but->type == UI_BTYPE_SEPR_SPACER) { /* How much the next block overlap with the current segment */ @@ -898,7 +898,7 @@ bool UI_but_active_only(const bContext *C, ARegion *region, uiBlock *block, uiBu bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, uiBlock *block) { bool done = false; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->flag & UI_BUT_ACTIVATE_ON_INIT) { but->flag &= ~UI_BUT_ACTIVATE_ON_INIT; if (ui_but_is_editable(but)) { @@ -913,7 +913,7 @@ bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, ui if (done) { /* Run this in a second pass since it's possible activating the button * removes the buttons being looped over. */ - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { but->flag &= ~UI_BUT_ACTIVATE_ON_INIT; } } @@ -970,7 +970,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) /* 2 Passes, on for first letter only, second for any letter if first fails * fun first pass on all buttons so first word chars always get first priority */ - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (!ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_BUT_MENU, @@ -1663,7 +1663,7 @@ static void ui_but_predefined_extra_operator_icons_add(uiBut *but) } if (optype) { - for (uiButExtraOpIcon *op_icon = but->extra_op_icons.first; op_icon; op_icon = op_icon->next) { + LISTBASE_FOREACH (uiButExtraOpIcon *, op_icon, &but->extra_op_icons) { if ((op_icon->optype_params->optype == optype) && (op_icon->icon == icon)) { /* Don't add the same operator icon twice (happens if button is kept alive while active). */ @@ -1934,7 +1934,7 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u { uiBut *but_prev = NULL; /* possibly we should keep the region this block is contained in? */ - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->rnapoin.type && but->rnaprop) { /* quick check to avoid adding buttons representing a vector, multiple times. */ if ((but_prev && (but_prev->rnaprop == but->rnaprop) && @@ -1959,7 +1959,7 @@ static void ui_block_message_subscribe(ARegion *region, struct wmMsgBus *mbus, u void UI_region_message_subscribe(ARegion *region, struct wmMsgBus *mbus) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { ui_block_message_subscribe(region, mbus, block); } } @@ -3274,7 +3274,7 @@ void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb) ARegion *region = CTX_wm_region(C); wmWindow *window = CTX_wm_window(C); - for (uiBlock *block = lb->first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, lb) { if (block->active) { ui_update_window_matrix(window, region, block); } @@ -3283,7 +3283,7 @@ void UI_blocklist_update_window_matrix(const bContext *C, const ListBase *lb) void UI_blocklist_draw(const bContext *C, const ListBase *lb) { - for (uiBlock *block = lb->first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, lb) { if (block->active) { UI_block_draw(C, block); } diff --git a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c index 925e9fdd6f9..3d32ede60c2 100644 --- a/source/blender/editors/interface/interface_eyedropper_gpencil_color.c +++ b/source/blender/editors/interface/interface_eyedropper_gpencil_color.c @@ -212,7 +212,7 @@ static void eyedropper_add_palette_color(bContext *C, float col_conv[4]) } /* Check if the color exist already. */ Palette *palette = paint->palette; - for (PaletteColor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) { + LISTBASE_FOREACH (PaletteColor *, palcolor, &palette->colors) { if (compare_v3v3(palcolor->rgb, col_conv, 0.01f)) { return; } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 04169b7d6dc..2b2d91f3a32 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1272,7 +1272,7 @@ static void ui_multibut_states_create(uiBut *but_active, uiHandleButtonData *dat data->multi_data.bs_mbuts = UI_butstore_create(but_active->block); - for (uiBut *but = but_active->block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &but_active->block->buttons) { if (but->flag & UI_BUT_DRAG_MULTI) { ui_multibut_add(data, but); } @@ -9241,7 +9241,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float if (dy < 0.0f) { /* Stop at top item, extra 0.5 UI_UNIT_Y makes it snap nicer. */ float ymax = -FLT_MAX; - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { ymax = max_ff(ymax, bt->rect.ymax); } if (ymax + dy - UI_UNIT_Y * 0.5f < block->rect.ymax - UI_MENU_SCROLL_PAD) { @@ -9251,7 +9251,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float else { /* Stop at bottom item, extra 0.5 UI_UNIT_Y makes it snap nicer. */ float ymin = FLT_MAX; - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { ymin = min_ff(ymin, bt->rect.ymin); } if (ymin + dy + UI_UNIT_Y * 0.5f > block->rect.ymin + UI_MENU_SCROLL_PAD) { @@ -9264,7 +9264,7 @@ static void ui_menu_scroll_apply_offset_y(ARegion *region, uiBlock *block, float block->handle->scrolloffset += dy; /* apply scroll offset */ - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { bt->rect.ymin += dy; bt->rect.ymax += dy; } @@ -9345,7 +9345,7 @@ static bool ui_menu_scroll_step(ARegion *region, uiBlock *block, const int scrol static void ui_region_auto_open_clear(ARegion *region) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { block->auto_open = false; } } @@ -10984,7 +10984,7 @@ void UI_screen_free_active_but(const bContext *C, bScreen *screen) ED_screen_areas_iter(win, screen, area) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { uiBut *but = ui_region_find_active_but(region); if (but) { uiHandleButtonData *data = but->active; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 6e86b60dc53..a28da678728 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2897,7 +2897,7 @@ void uiItemPopoverPanelFromGroup(uiLayout *layout, return; } - for (PanelType *pt = art->paneltypes.first; pt; pt = pt->next) { + LISTBASE_FOREACH (PanelType *, pt, &art->paneltypes) { /* Causes too many panels, check context. */ if (pt->parent_id[0] == '\0') { if (/* (*context == '\0') || */ STREQ(pt->context, context)) { @@ -5352,7 +5352,7 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout, MEM_freeN(panel); /* Draw child panels. */ - for (LinkData *link = pt->children.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &pt->children) { PanelType *child_pt = link->data; if (child_pt->poll == NULL || child_pt->poll(C, child_pt)) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 04d1181a8a1..42179452279 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -160,7 +160,7 @@ static int panel_aligned(const ScrArea *area, const ARegion *region) static bool panel_active_animation_changed(ListBase *lb, Panel **pa_animation, bool *no_animation) { - for (Panel *pa = lb->first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, lb) { /* Detect panel active flag changes. */ if (!(pa->type && pa->type->parent)) { if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) { @@ -394,7 +394,7 @@ void UI_panel_end( pa->blocksizey = height; /* Compute total panel size including children. */ - for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) { + LISTBASE_FOREACH (Panel *, pachild, &pa->children) { if (pachild->runtime_flag & PNL_ACTIVE) { width = max_ii(width, pachild->sizex); height += get_panel_real_size_y(pachild); @@ -441,7 +441,7 @@ static void ui_offset_panel_block(uiBlock *block) int ofsy = block->panel->sizey - style->panelspace; - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { but->rect.ymin += ofsy; but->rect.ymax += ofsy; } @@ -1006,7 +1006,7 @@ static void align_sub_panels(Panel *pa) /* Position sub panels. */ int ofsy = pa->ofsy + pa->sizey - pa->blocksizey; - for (Panel *pachild = pa->children.first; pachild; pachild = pachild->next) { + LISTBASE_FOREACH (Panel *, pachild, &pa->children) { if (pachild->runtime_flag & PNL_ACTIVE) { pachild->ofsx = pa->ofsx; pachild->ofsy = ofsy - get_panel_size_y(pachild); @@ -1200,7 +1200,7 @@ static void panel_list_clear_active(ListBase *lb) { /* set all panels as inactive, so that at the end we know * which ones were used */ - for (Panel *pa = lb->first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, lb) { if (pa->runtime_flag & PNL_ACTIVE) { pa->runtime_flag = PNL_WAS_ACTIVE; } diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 8ba3e5db426..70b4660e392 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -261,7 +261,7 @@ uiBut *ui_but_find_mouse_over_ex(ARegion *region, const int x, const int y, cons if (!ui_region_contains_point_px(region, x, y)) { return NULL; } - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { float mx = x, my = y; ui_window_to_block_fl(region, block, &mx, &my); @@ -309,7 +309,7 @@ uiBut *ui_but_find_rect_over(const struct ARegion *region, const rcti *rect_px) BLI_rctf_rcti_copy(&rect_px_fl, rect_px); uiBut *butover = NULL; - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { rctf rect_block; ui_window_to_block_rctf(region, block, &rect_block, &rect_px_fl); @@ -340,7 +340,7 @@ uiBut *ui_list_find_mouse_over_ex(ARegion *region, int x, int y) if (!ui_region_contains_point_px(region, x, y)) { return NULL; } - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { float mx = x, my = y; ui_window_to_block_fl(region, block, &mx, &my); for (uiBut *but = block->buttons.last; but; but = but->prev) { @@ -517,7 +517,7 @@ uiBlock *ui_block_find_mouse_over_ex(const ARegion *region, if (!ui_region_contains_point_px(region, x, y)) { return NULL; } - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { if (only_clip) { if ((block->flag & UI_BLOCK_CLIP_EVENTS) == 0) { continue; @@ -545,8 +545,8 @@ uiBlock *ui_block_find_mouse_over(const ARegion *region, const wmEvent *event, b uiBut *ui_region_find_active_but(ARegion *region) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->active) { return but; } @@ -558,8 +558,8 @@ uiBut *ui_region_find_active_but(ARegion *region) uiBut *ui_region_find_first_but_test_flag(ARegion *region, int flag_include, int flag_exclude) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { - for (uiBut *but = block->buttons.first; but; but = but->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { + LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (((but->flag & flag_include) == flag_include) && ((but->flag & flag_exclude) == 0)) { return but; } @@ -633,7 +633,7 @@ bool ui_region_contains_rect_px(const ARegion *region, const rcti *rect_px) /** Check if the cursor is over any popups. */ ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y) { - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { rcti winrct; ui_region_winrct_get_no_margin(region, &winrct); diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c index ecdcd575d5c..f9873f8b96f 100644 --- a/source/blender/editors/interface/interface_region_color_picker.c +++ b/source/blender/editors/interface/interface_region_color_picker.c @@ -332,7 +332,7 @@ static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) static void ui_colorpicker_hide_reveal(uiBlock *block, enum ePickerType colormode) { /* tag buttons */ - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { if ((bt->func == ui_colorpicker_rna_cb) && (bt->type == UI_BTYPE_NUM_SLIDER) && (bt->rnaindex != 3)) { /* RGB sliders (color circle and alpha are always shown) */ diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index a7508894c54..1963c76b96e 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -278,11 +278,11 @@ static ARegion *hud_region_add(ScrArea *area) void ED_area_type_hud_clear(wmWindowManager *wm, ScrArea *area_keep) { - 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 != area_keep) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->regiontype == RGN_TYPE_HUD) { if ((region->flag & RGN_FLAG_HIDDEN) == 0) { hud_region_hide(region); diff --git a/source/blender/editors/interface/interface_region_menu_popup.c b/source/blender/editors/interface/interface_region_menu_popup.c index dbec8e6d653..a161a449ba0 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.c +++ b/source/blender/editors/interface/interface_region_menu_popup.c @@ -669,7 +669,7 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block) /* In the case we have nested popups, * closing one may need to redraw another, see: T48874 */ - for (ARegion *region = screen->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { ED_region_tag_refresh_ui(region); } } @@ -678,8 +678,8 @@ void UI_popup_block_close(bContext *C, wmWindow *win, uiBlock *block) bool UI_popup_block_name_exists(const bScreen *screen, const char *name) { - for (const ARegion *region = screen->regionbase.first; region; region = region->next) { - for (const uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (const ARegion *, region, &screen->regionbase) { + LISTBASE_FOREACH (const uiBlock *, block, ®ion->uiblocks) { if (STREQ(block->name, name)) { return true; } diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index a51558e4cfe..2ad7e517c60 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -118,7 +118,7 @@ static void ui_popup_block_position(wmWindow *window, if (block->buttons.first) { BLI_rctf_init_minmax(&block->rect); - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { if (block->content_hints & UI_BLOCK_CONTAINS_SUBMENU_BUT) { bt->rect.xmax += UI_MENU_SUBMENU_PADDING; } @@ -294,7 +294,7 @@ static void ui_popup_block_position(wmWindow *window, } /* Apply offset, buttons in window coords. */ - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { ui_block_to_window_rctf(butregion, but->block, &bt->rect, &bt->rect); BLI_rctf_translate(&bt->rect, offset_x, offset_y); @@ -698,7 +698,7 @@ uiBlock *ui_popup_block_refresh(bContext *C, /* lastly set the buttons at the center of the pie menu, ready for animation */ if (U.pie_animation_timeout > 0) { - for (uiBut *but_iter = block->buttons.first; but_iter; but_iter = but_iter->next) { + LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) { if (but_iter->pie_dir != UI_RADIAL_NONE) { BLI_rctf_recenter(&but_iter->rect, UNPACK2(block->pie_data.pie_center_spawned)); } @@ -742,7 +742,7 @@ uiBlock *ui_popup_block_refresh(bContext *C, /* apply scroll offset */ if (handle->scrolloffset != 0.0f) { - for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { + LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { bt->rect.ymin += handle->scrolloffset; bt->rect.ymax += handle->scrolloffset; } @@ -846,7 +846,7 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) * then close the popover too. We could extend this to other popup types too. */ ARegion *region = handle->popup_create_vars.butregion; if (region != NULL) { - for (uiBlock *block = region->uiblocks.first; block; block = block->next) { + LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) { if (block->handle && (block->flag & UI_BLOCK_POPOVER) && (block->flag & UI_BLOCK_KEEP_OPEN) == 0) { uiPopupBlockHandle *menu = block->handle; diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index 8b41d92ea74..58a13c6c456 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -319,7 +319,7 @@ static bool ui_tooltip_data_append_from_keymap(bContext *C, uiTooltipData *data, const int fields_len_init = data->fields_len; char buf[512]; - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { wmOperatorType *ot = WM_operatortype_find(kmi->idname, true); if (ot != NULL) { /* Tip */ @@ -597,7 +597,7 @@ static uiTooltipData *ui_tooltip_data_from_tool(bContext *C, uiBut *but, bool is else if (BPY_execute_string_as_intptr(C, expr_imports, expr, true, &expr_result)) { if (expr_result != 0) { wmKeyMap *keymap = (wmKeyMap *)expr_result; - for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) { + LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) { if (STREQ(kmi->idname, but->optype->idname)) { char tool_id_test[MAX_NAME]; RNA_string_get(kmi->ptr, "name", tool_id_test); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6bd956c87b0..ba7cd708bfa 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1159,7 +1159,7 @@ static void template_ID_tabs(bContext *C, ListBase ordered; BKE_id_ordered_list(&ordered, template->idlb); - for (LinkData *link = ordered.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &ordered) { ID *id = link->data; const int name_width = UI_fontstyle_string_width(&style->widgetlabel, id->name + 2); const int but_width = name_width + UI_UNIT_X; @@ -2428,7 +2428,7 @@ static void template_operator_redo_property_buts_draw( const bContext *C, wmOperator *op, uiLayout *layout, int layout_flags, bool *r_has_advanced) { if (op->type->flag & OPTYPE_MACRO) { - for (wmOperator *macro_op = op->macro.first; macro_op; macro_op = macro_op->next) { + LISTBASE_FOREACH (wmOperator *, macro_op, &op->macro) { template_operator_redo_property_buts_draw(C, macro_op, layout, layout_flags, r_has_advanced); } } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 97a3a7eefe4..c07166b9ad2 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -269,7 +269,6 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) */ v2d->align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y); v2d->keeptot = V2D_KEEPTOT_BOUNDS; - if (do_init) { v2d->tot.xmin = v2d->tot.ymin = 0.0f; v2d->tot.xmax = (float)(winx - 1); @@ -900,7 +899,7 @@ void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag) /* check if doing whole screen syncing (i.e. time/horizontal) */ if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) { - for (ScrArea *area_iter = screen->areabase.first; area_iter; area_iter = area_iter->next) { + LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) { for (region = area_iter->regionbase.first; region; region = region->next) { /* don't operate on self */ if (v2dcur != ®ion->v2d) { |