[Bf-blender-cvs] [75aeb4b8813] master: Cleanup: Use LISTBASE_FOREACH in editors/screen directory

Hans Goudey noreply at git.blender.org
Fri Aug 21 02:48:00 CEST 2020


Commit: 75aeb4b8813d123a40ae63b5ca47c62749f6e75d
Author: Hans Goudey
Date:   Thu Aug 20 20:47:44 2020 -0400
Branches: master
https://developer.blender.org/rB75aeb4b8813d123a40ae63b5ca47c62749f6e75d

Cleanup: Use LISTBASE_FOREACH in editors/screen directory

Differential Revision: https://developer.blender.org/D8653

===================================================================

M	source/blender/editors/screen/area.c
M	source/blender/editors/screen/screen_context.c
M	source/blender/editors/screen/screen_draw.c
M	source/blender/editors/screen/screen_edit.c
M	source/blender/editors/screen/screen_geometry.c
M	source/blender/editors/screen/screen_ops.c
M	source/blender/editors/screen/workspace_edit.c
M	source/blender/editors/screen/workspace_layout_edit.c

===================================================================

diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 27a641dc6d8..80fa5a7815d 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -302,8 +302,6 @@ static void area_azone_tag_update(ScrArea *area)
 
 static void region_draw_azones(ScrArea *area, ARegion *region)
 {
-  AZone *az;
-
   if (!area) {
     return;
   }
@@ -314,7 +312,7 @@ static void region_draw_azones(ScrArea *area, ARegion *region)
   GPU_matrix_push();
   GPU_matrix_translate_2f(-region->winrct.xmin, -region->winrct.ymin);
 
-  for (az = area->actionzones.first; az; az = az->next) {
+  LISTBASE_FOREACH (AZone *, az, &area->actionzones) {
     /* test if action zone is over this region */
     rcti azrct;
     BLI_rcti_init(&azrct, az->x1, az->x2, az->y1, az->y2);
@@ -705,10 +703,8 @@ void ED_region_tag_redraw_partial(ARegion *region, const rcti *rct, bool rebuild
 
 void ED_area_tag_redraw(ScrArea *area)
 {
-  ARegion *region;
-
   if (area) {
-    for (region = area->regionbase.first; region; region = region->next) {
+    LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
       ED_region_tag_redraw(region);
     }
   }
@@ -716,10 +712,8 @@ void ED_area_tag_redraw(ScrArea *area)
 
 void ED_area_tag_redraw_no_rebuild(ScrArea *area)
 {
-  ARegion *region;
-
   if (area) {
-    for (region = area->regionbase.first; region; region = region->next) {
+    LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
       ED_region_tag_redraw_no_rebuild(region);
     }
   }
@@ -727,10 +721,8 @@ void ED_area_tag_redraw_no_rebuild(ScrArea *area)
 
 void ED_area_tag_redraw_regiontype(ScrArea *area, int regiontype)
 {
-  ARegion *region;
-
   if (area) {
-    for (region = area->regionbase.first; region; region = region->next) {
+    LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
       if (region->regiontype == regiontype) {
         ED_region_tag_redraw(region);
       }
@@ -750,14 +742,12 @@ void ED_area_tag_refresh(ScrArea *area)
 /* use NULL to disable it */
 void ED_area_status_text(ScrArea *area, const char *str)
 {
-  ARegion *region;
-
   /* happens when running transform operators in background mode */
   if (area == NULL) {
     return;
   }
 
-  for (region = area->regionbase.first; region; region = region->next) {
+  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
     if (region->regiontype == RGN_TYPE_HEADER) {
       if (str) {
         if (region->headerstr == NULL) {
@@ -942,7 +932,6 @@ static void region_azone_edge(AZone *az, ARegion *region)
 /* region already made zero sized, in shape of edge */
 static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region)
 {
-  AZone *azt;
   int tot = 0, add;
   /* Edge offset multiplied by the  */
 
@@ -950,7 +939,7 @@ static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region)
   const float tab_size_x = 0.7f * U.widget_unit;
   const float tab_size_y = 0.4f * U.widget_unit;
 
-  for (azt = area->actionzones.first; azt; azt = azt->next) {
+  LISTBASE_FOREACH (AZone *, azt, &area->actionzones) {
     if (azt->edge == az->edge) {
       tot++;
     }
@@ -1846,7 +1835,6 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
   WorkSpace *workspace = WM_window_get_active_workspace(win);
   const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
   ViewLayer *view_layer = WM_window_get_active_view_layer(win);
-  ARegion *region;
   rcti rect, overlap_rect;
   rcti window_rect;
 
@@ -1863,7 +1851,7 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
     area->type = BKE_spacetype_from_id(area->spacetype);
   }
 
-  for (region = area->regionbase.first; region; region = region->next) {
+  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
     region->type = BKE_regiontype_from_id_or_first(area->type, region->regiontype);
   }
 
@@ -1887,7 +1875,7 @@ void ED_area_init(wmWindowManager *wm, wmWindow *win, ScrArea *area)
   area_azone_init(win, screen, area);
 
   /* region windows, default and own handlers */
-  for (region = area->regionbase.first; region; region = region->next) {
+  LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
     region_subwindow(region);
 
     if (region->visible) {
@@ -2006,7 +1994,6 @@ void ED_region_toggle_hidden(bContext *C, ARegion *region)
 void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free)
 {
   SpaceType *st;
-  ARegion *region;
   const char spacetype = area_dst->spacetype;
   const short flag_copy = HEADER_NO_PULLDOWN;
 
@@ -2026,13 +2013,13 @@ void ED_area_data_copy(ScrArea *area_dst, ScrArea *area_src, const bool do_free)
   /* regions */
   if (do_free) {
     st = BKE_spacetype_from_id(spacetype);
-    for (region = area_dst->regionbase.first; region; region = region->next) {
+    LISTBASE_FOREACH (ARegion *, region, &area_dst->regionbase) {
       BKE_area_region_free(st, region);
     }
     BLI_freelistN(&area_dst->regionbase);
   }
   st = BKE_spacetype_from_id(area_src->spacetype);
-  for (region = area_src->regionbase.first; region; region = region->next) {
+  LISTBASE_FOREACH (ARegion *, region, &area_src->regionbase) {
     ARegion *newar = BKE_area_region_copy(st, region);
     BLI_addtail(&area_dst->regionbase, newar);
   }
@@ -2320,7 +2307,6 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
   if (area->spacetype != type) {
     SpaceType *st;
     SpaceLink *slold = area->spacedata.first;
-    SpaceLink *sl;
     /* store area->type->exit callback */
     void *area_exit = area->type ? area->type->exit : NULL;
     /* When the user switches between space-types from the type-selector,
@@ -2364,8 +2350,10 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
      * (e.g. with properties editor) until space-data is properly created */
 
     /* check previously stored space */
-    for (sl = area->spacedata.first; sl; sl = sl->next) {
-      if (sl->spacetype == type) {
+    SpaceLink *sl = NULL;
+    LISTBASE_FOREACH (SpaceLink *, sl_iter, &area->spacedata) {
+      if (sl_iter->spacetype == type) {
+        sl = sl_iter;
         break;
       }
     }
@@ -2714,7 +2702,7 @@ void ED_region_panels_layout_ex(const bContext *C,
   /* collect panels to draw */
   WorkSpace *workspace = CTX_wm_workspace(C);
   LinkNode *panel_types_stack = NULL;
-  for (PanelType *pt = paneltypes->last; pt; pt = pt->prev) {
+  LISTBASE_FOREACH_BACKWARD (PanelType *, pt, paneltypes) {
     /* Only draw top level panels. */
     if (pt->parent) {
       continue;
@@ -2991,7 +2979,6 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
   const uiStyle *style = UI_style_get_dpi();
   uiBlock *block;
   uiLayout *layout;
-  HeaderType *ht;
   Header header = {NULL};
   bool region_layout_based = region->flag & RGN_FLAG_DYNAMIC_SIZE;
 
@@ -3014,7 +3001,7 @@ void ED_region_header_layout(const bContext *C, ARegion *region)
   UI_view2d_view_ortho(&region->v2d);
 
   /* draw all headers types */
-  for (ht = region->type->headertypes.first; ht; ht = ht->next) {
+  LISTBASE_FOREACH (HeaderType *, ht, &region->type->headertypes) {
     if (ht->poll && !ht->poll(C, ht)) {
       continue;
     }
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index c17a34f97b9..3c70bf1bfd8 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -204,7 +204,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
   }
   if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) {
     bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
-    EditBone *ebone, *flipbone = NULL;
+    EditBone *flipbone = NULL;
     const bool editable_bones = CTX_data_equals(member, "editable_bones");
 
     if (arm && arm->edbo) {
@@ -216,7 +216,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
         arm = ob->data;
 
         /* Attention: X-Axis Mirroring is also handled here... */
-        for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+        LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
           /* first and foremost, bone must be visible and selected */
           if (EBONE_VISIBLE(arm, ebone)) {
             /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
@@ -262,7 +262,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
   if (CTX_data_equals(member, "selected_bones") ||
       CTX_data_equals(member, "selected_editable_bones")) {
     bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL;
-    EditBone *ebone, *flipbone = NULL;
+    EditBone *flipbone = NULL;
     const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones");
 
     if (arm && arm->edbo) {
@@ -274,7 +274,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
         arm = ob->data;
 
         /* Attention: X-Axis Mirroring is also handled here... */
-        for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+        LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
           /* first and foremost, bone must be visible and selected */
           if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) {
             /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled
@@ -479,8 +479,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
   if (CTX_data_equals(member, "sequences")) {
     Editing *ed = BKE_sequencer_editing_get(scene, false);
     if (ed) {
-      Sequence *seq;
-      for (seq = ed->seqbasep->first; seq; seq = seq->next) {
+      LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
         CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq);
       }
       CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION);
@@ -491,8 +490,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
   if (CTX_data_equals(member, "selected_sequences

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list