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/makesrna/intern | |
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/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_access_compare_override.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_key.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_layer.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm_gizmo.c | 9 |
8 files changed, 20 insertions, 21 deletions
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 4e238df4e3c..199d22ee3dc 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -438,7 +438,7 @@ static bool rna_property_override_operation_store(Main *bmain, return changed; } - for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { + LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { /* Only needed for diff operations. */ if (!ELEM(opop->operation, IDOVERRIDE_LIBRARY_OP_ADD, @@ -832,7 +832,7 @@ bool RNA_struct_override_store(Main *bmain, #ifdef DEBUG_OVERRIDE_TIMEIT TIMEIT_START_AVERAGED(RNA_struct_override_store); #endif - for (IDOverrideLibraryProperty *op = override->properties.first; op; op = op->next) { + LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &override->properties) { /* Simplified for now! */ PointerRNA data_reference, data_local; PropertyRNA *prop_reference, *prop_local; @@ -880,7 +880,7 @@ static void rna_property_override_apply_ex(Main *bmain, IDOverrideLibraryProperty *op, const bool do_insert) { - for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop; opop = opop->next) { + LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) { if (!do_insert != !ELEM(opop->operation, IDOVERRIDE_LIBRARY_OP_INSERT_AFTER, IDOVERRIDE_LIBRARY_OP_INSERT_BEFORE)) { @@ -999,7 +999,7 @@ void RNA_struct_override_apply(Main *bmain, */ bool do_insert = false; for (int i = 0; i < 2; i++, do_insert = true) { - for (IDOverrideLibraryProperty *op = override->properties.first; op; op = op->next) { + LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &override->properties) { /* Simplified for now! */ PointerRNA data_src, data_dst; PointerRNA data_item_src, data_item_dst; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 6755dd86a0a..7955109d9bc 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -576,7 +576,7 @@ static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA NurbInfo info = {0}; /* Check if all sub-curves have the same type. */ - for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { if (type == NULL) { type = rna_ShapeKey_curve_point_type(nu); rna_ShapeKey_NurbInfo_init(&info, nu); diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index f3e2e20ee3c..46a32256114 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -301,7 +301,7 @@ static void rna_LayerCollection_hide_viewport_set(PointerRNA *ptr, bool value) static void rna_LayerCollection_exclude_update_recursive(ListBase *lb, const bool exclude) { - for (LayerCollection *lc = lb->first; lc; lc = lc->next) { + LISTBASE_FOREACH (LayerCollection *, lc, lb) { if (exclude) { lc->flag |= LAYER_COLLECTION_EXCLUDE; } diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index d062642d3ce..c1fb3232bb3 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -697,7 +697,7 @@ static void rna_Particle_change_type(Main *bmain, Scene *UNUSED(scene), PointerR /* Iterating over all object is slow, but no better solution exists at the moment. */ for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { - for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) { + LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { if (psys->part == part) { psys_changed_type(ob, psys); psys->recalc |= ID_RECALC_PSYS_RESET; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f68541dfc4a..27ebbe79085 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1811,7 +1811,7 @@ static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const bool *valu /* Update select mode in all the workspaces in mesh edit mode. */ wmWindowManager *wm = G_MAIN->wm.first; - for (wmWindow *win = wm->windows.first; win; win = win->next) { + LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { ViewLayer *view_layer = WM_window_get_active_view_layer(win); if (view_layer && view_layer->basact) { @@ -2435,7 +2435,7 @@ static const EnumPropertyItem *rna_TransformOrientation_impl_itemf(Scene *scene, if (transform_orientations && (BLI_listbase_is_empty(transform_orientations) == false)) { RNA_enum_item_add_separator(&item, &totitem); - for (TransformOrientation *ts = transform_orientations->first; ts; ts = ts->next) { + LISTBASE_FOREACH (TransformOrientation *, ts, transform_orientations) { tmp.identifier = ts->name; tmp.name = ts->name; tmp.value = i++; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e20bf263bee..f69ba1a38c9 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1028,8 +1028,8 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA rna_GPencil_update(bmain, scene, ptr); bScreen *screen = (bScreen *)ptr->owner_id; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (&v3d->shading == shading) { diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 37cbeeb0d84..a94e3d26862 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -204,7 +204,7 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type) WM_paneltype_remove(pt); - for (LinkData *link = pt->children.first; link; link = link->next) { + LISTBASE_FOREACH (LinkData *, link, &pt->children) { PanelType *child_pt = link->data; child_pt->parent = NULL; } @@ -214,14 +214,14 @@ static void rna_Panel_unregister(Main *bmain, StructRNA *type) BLI_freelinkN(&art->paneltypes, pt); for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == space_type) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - for (ARegion *region = regionbase->first; region; region = region->next) { + LISTBASE_FOREACH (ARegion *, region, regionbase) { if (region->type == art) { - for (Panel *pa = region->panels.first; pa; pa = pa->next) { + LISTBASE_FOREACH (Panel *, pa, ®ion->panels) { if (pa->type == pt) { pa->type = NULL; } diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index 8c1b48d2b07..826d4039c55 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -259,13 +259,12 @@ static wmGizmo *rna_GizmoProperties_find_operator(PointerRNA *ptr) /* We could try workaruond this lookup, but not trivial. */ for (bScreen *screen = G_MAIN->screens.first; screen; screen = screen->id.next) { IDProperty *properties = ptr->data; - for (ScrArea *area = screen->areabase.first; area; area = area->next) { - for (ARegion *region = area->regionbase.first; region; region = region->next) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->gizmo_map) { wmGizmoMap *gzmap = region->gizmo_map; - for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup; - gzgroup = gzgroup->next) { - for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) { + LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, WM_gizmomap_group_list(gzmap)) { + LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { if (gz->properties == properties) { return gz; } |