Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorDalai Felinto <dalai@blender.org>2020-04-03 20:15:01 +0300
committerDalai Felinto <dalai@blender.org>2020-04-03 20:27:46 +0300
commitd138cbfb47e379edc1ee915a8c6ff65b01f000d6 (patch)
treef4773ecce897c32eaf75295dd5f6a8e730d471ed /source
parentb0c1184875d39abac4a65a5d20e263ea6d841009 (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')
-rw-r--r--source/blender/blenkernel/intern/anim_data.c2
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c16
-rw-r--r--source/blender/blenkernel/intern/armature.c12
-rw-r--r--source/blender/blenkernel/intern/blender.c6
-rw-r--r--source/blender/blenkernel/intern/blender_user_menu.c2
-rw-r--r--source/blender/blenkernel/intern/blendfile.c2
-rw-r--r--source/blender/blenkernel/intern/camera.c2
-rw-r--r--source/blender/blenkernel/intern/collection.c42
-rw-r--r--source/blender/blenkernel/intern/collision.c4
-rw-r--r--source/blender/blenkernel/intern/constraint.c6
-rw-r--r--source/blender/blenkernel/intern/curve.c8
-rw-r--r--source/blender/blenkernel/intern/effect.c6
-rw-r--r--source/blender/blenkernel/intern/fcurve.c6
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c2
-rw-r--r--source/blender/blenkernel/intern/gpencil.c4
-rw-r--r--source/blender/blenkernel/intern/gpencil_geom.c4
-rw-r--r--source/blender/blenkernel/intern/idprop.c2
-rw-r--r--source/blender/blenkernel/intern/idprop_utils.c2
-rw-r--r--source/blender/blenkernel/intern/image.c14
-rw-r--r--source/blender/blenkernel/intern/keyconfig.c2
-rw-r--r--source/blender/blenkernel/intern/layer.c117
-rw-r--r--source/blender/blenkernel/intern/lib_id.c12
-rw-r--r--source/blender/blenkernel/intern/lib_override.c4
-rw-r--r--source/blender/blenkernel/intern/lib_query.c44
-rw-r--r--source/blender/blenkernel/intern/material.c2
-rw-r--r--source/blender/blenkernel/intern/mball.c23
-rw-r--r--source/blender/blenkernel/intern/node.c12
-rw-r--r--source/blender/blenkernel/intern/particle.c2
-rw-r--r--source/blender/blenkernel/intern/pointcache.c2
-rw-r--r--source/blender/blenkernel/intern/scene.c24
-rw-r--r--source/blender/blenkernel/intern/screen.c10
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c1
-rw-r--r--source/blender/blenkernel/intern/sequencer.c2
-rw-r--r--source/blender/blenkernel/intern/text.c6
-rw-r--r--source/blender/blenkernel/intern/texture.c2
-rw-r--r--source/blender/blenkernel/intern/tracking_solver.c2
-rw-r--r--source/blender/blenkernel/intern/undo_system.c8
-rw-r--r--source/blender/blenkernel/intern/workspace.c2
-rw-r--r--source/blender/blenlib/intern/array_store.c18
-rw-r--r--source/blender/blenlib/intern/threads.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c134
-rw-r--r--source/blender/blenloader/intern/undofile.c2
-rw-r--r--source/blender/blenloader/intern/versioning_270.c40
-rw-r--r--source/blender/blenloader/intern/versioning_280.c324
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c48
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c34
-rw-r--r--source/blender/blenloader/intern/versioning_userdef.c10
-rw-r--r--source/blender/blenloader/intern/writefile.c102
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_volumes.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c12
-rw-r--r--source/blender/draw/engines/overlay/overlay_extra.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_image.c2
-rw-r--r--source/blender/draw/engines/overlay/overlay_motion_path.c2
-rw-r--r--source/blender/draw/engines/workbench/workbench_volume.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c16
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c16
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_volume.c2
-rw-r--r--source/blender/draw/intern/draw_manager.c17
-rw-r--r--source/blender/draw/intern/draw_manager_data.c6
-rw-r--r--source/blender/draw/intern/draw_manager_profiling.c2
-rw-r--r--source/blender/draw/intern/draw_manager_shader.c2
-rw-r--r--source/blender/editors/animation/anim_filter.c4
-rw-r--r--source/blender/editors/animation/anim_markers.c12
-rw-r--r--source/blender/editors/animation/anim_motion_paths.c8
-rw-r--r--source/blender/editors/animation/keyframes_draw.c14
-rw-r--r--source/blender/editors/armature/armature_add.c4
-rw-r--r--source/blender/editors/armature/armature_edit.c12
-rw-r--r--source/blender/editors/armature/armature_naming.c9
-rw-r--r--source/blender/editors/armature/armature_relations.c14
-rw-r--r--source/blender/editors/armature/armature_select.c42
-rw-r--r--source/blender/editors/armature/armature_utils.c10
-rw-r--r--source/blender/editors/armature/editarmature_undo.c2
-rw-r--r--source/blender/editors/armature/pose_select.c2
-rw-r--r--source/blender/editors/armature/pose_transform.c4
-rw-r--r--source/blender/editors/curve/editcurve.c4
-rw-r--r--source/blender/editors/curve/editcurve_select.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c4
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c24
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_ops_versioning.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c2
-rw-r--r--source/blender/editors/interface/interface.c22
-rw-r--r--source/blender/editors/interface/interface_eyedropper_gpencil_color.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c12
-rw-r--r--source/blender/editors/interface/interface_layout.c4
-rw-r--r--source/blender/editors/interface/interface_panel.c10
-rw-r--r--source/blender/editors/interface/interface_query.c18
-rw-r--r--source/blender/editors/interface/interface_region_color_picker.c2
-rw-r--r--source/blender/editors/interface/interface_region_hud.c6
-rw-r--r--source/blender/editors/interface/interface_region_menu_popup.c6
-rw-r--r--source/blender/editors/interface/interface_region_popup.c10
-rw-r--r--source/blender/editors/interface/interface_region_tooltip.c4
-rw-r--r--source/blender/editors/interface/interface_templates.c4
-rw-r--r--source/blender/editors/interface/view2d.c3
-rw-r--r--source/blender/editors/mask/mask_draw.c2
-rw-r--r--source/blender/editors/mask/mask_ops.c28
-rw-r--r--source/blender/editors/mask/mask_relationships.c8
-rw-r--r--source/blender/editors/mask/mask_select.c35
-rw-r--r--source/blender/editors/mask/mask_shapekey.c16
-rw-r--r--source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c2
-rw-r--r--source/blender/editors/mesh/editmesh_utils.c3
-rw-r--r--source/blender/editors/mesh/meshtools.c6
-rw-r--r--source/blender/editors/metaball/mball_edit.c4
-rw-r--r--source/blender/editors/object/object_add.c4
-rw-r--r--source/blender/editors/object/object_data_transform.c4
-rw-r--r--source/blender/editors/object/object_edit.c10
-rw-r--r--source/blender/editors/object/object_relations.c8
-rw-r--r--source/blender/editors/object/object_select.c4
-rw-r--r--source/blender/editors/object/object_utils.c4
-rw-r--r--source/blender/editors/object/object_volume.c2
-rw-r--r--source/blender/editors/render/render_internal.c6
-rw-r--r--source/blender/editors/render/render_preview.c6
-rw-r--r--source/blender/editors/render/render_update.c4
-rw-r--r--source/blender/editors/scene/scene_edit.c4
-rw-r--r--source/blender/editors/screen/area.c14
-rw-r--r--source/blender/editors/screen/screen_context.c14
-rw-r--r--source/blender/editors/screen/screen_draw.c4
-rw-r--r--source/blender/editors/screen/screen_edit.c32
-rw-r--r--source/blender/editors/screen/screen_geometry.c10
-rw-r--r--source/blender/editors/screen/screen_ops.c30
-rw-r--r--source/blender/editors/screen/screen_user_menu.c8
-rw-r--r--source/blender/editors/screen/workspace_edit.c9
-rw-r--r--source/blender/editors/screen/workspace_layout_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_ops.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c6
-rw-r--r--source/blender/editors/space_action/action_draw.c2
-rw-r--r--source/blender/editors/space_action/action_select.c4
-rw-r--r--source/blender/editors/space_action/space_action.c2
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c2
-rw-r--r--source/blender/editors/space_clip/clip_editor.c4
-rw-r--r--source/blender/editors/space_image/image_ops.c6
-rw-r--r--source/blender/editors/space_image/image_sequence.c2
-rw-r--r--source/blender/editors/space_image/image_undo.c22
-rw-r--r--source/blender/editors/space_info/info_report.c4
-rw-r--r--source/blender/editors/space_nla/nla_channels.c2
-rw-r--r--source/blender/editors/space_nla/nla_draw.c8
-rw-r--r--source/blender/editors/space_nla/nla_select.c2
-rw-r--r--source/blender/editors/space_node/node_edit.c4
-rw-r--r--source/blender/editors/space_node/node_relationships.c2
-rw-r--r--source/blender/editors/space_node/node_select.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_collections.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_dragdrop.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c33
-rw-r--r--source/blender/editors/space_outliner/outliner_edit.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_sync.c8
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c19
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c10
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c4
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c2
-rw-r--r--source/blender/editors/transform/transform_convert.c13
-rw-r--r--source/blender/editors/transform/transform_convert_armature.c9
-rw-r--r--source/blender/editors/transform/transform_convert_curve.c4
-rw-r--r--source/blender/editors/transform/transform_convert_object.c18
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c6
-rw-r--r--source/blender/editors/transform/transform_snap_object.c4
-rw-r--r--source/blender/editors/undo/ed_undo.c8
-rw-r--r--source/blender/editors/util/ed_util.c2
-rw-r--r--source/blender/gpu/intern/gpu_batch_presets.c2
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c20
-rw-r--r--source/blender/gpu/intern/gpu_material.c4
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.c4
-rw-r--r--source/blender/gpu/intern/gpu_select_pick.c3
-rw-r--r--source/blender/gpu/intern/gpu_uniformbuffer.c6
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c4
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c2
-rw-r--r--source/blender/makesrna/intern/rna_access_compare_override.c8
-rw-r--r--source/blender/makesrna/intern/rna_key.c2
-rw-r--r--source/blender/makesrna/intern/rna_layer.c2
-rw-r--r--source/blender/makesrna/intern/rna_particle.c2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c4
-rw-r--r--source/blender/makesrna/intern/rna_space.c4
-rw-r--r--source/blender/makesrna/intern/rna_ui.c10
-rw-r--r--source/blender/makesrna/intern/rna_wm_gizmo.c9
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c3
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_displacement.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_brick.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_principled.c4
-rw-r--r--source/blender/python/intern/bpy_capi_utils.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c7
-rw-r--r--source/blender/render/intern/source/render_result.c16
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c30
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c51
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c6
-rw-r--r--source/blender/windowmanager/intern/wm_dragdrop.c4
-rw-r--r--source/blender/windowmanager/intern/wm_draw.c25
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c22
-rw-r--r--source/blender/windowmanager/intern/wm_files.c8
-rw-r--r--source/blender/windowmanager/intern/wm_jobs.c2
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c6
-rw-r--r--source/blender/windowmanager/intern/wm_keymap_utils.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c8
-rw-r--r--source/blender/windowmanager/intern/wm_surface.c2
-rw-r--r--source/blender/windowmanager/intern/wm_toolsystem.c28
-rw-r--r--source/blender/windowmanager/intern/wm_window.c19
-rw-r--r--source/blender/windowmanager/message_bus/intern/wm_message_bus.c11
207 files changed, 1174 insertions, 1251 deletions
diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c
index cd56796c3cf..41bfc5b59e4 100644
--- a/source/blender/blenkernel/intern/anim_data.c
+++ b/source/blender/blenkernel/intern/anim_data.c
@@ -1130,7 +1130,7 @@ bool BKE_animdata_fix_paths_remove(ID *id, const char *prefix)
/* free drivers - stored as a list of F-Curves */
any_removed |= fcurves_path_remove_fix(prefix, &adt->drivers);
/* NLA Data - Animation Data for Strips */
- for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
+ LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
any_removed |= nlastrips_path_remove_fix(prefix, &nlt->strips);
}
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index 69efac37fbf..18320ef0f8d 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -542,7 +542,7 @@ static void animsys_evaluate_fcurves(PointerRNA *ptr,
bool flush_to_original)
{
/* Calculate then execute each curve. */
- for (FCurve *fcu = list->first; fcu; fcu = fcu->next) {
+ LISTBASE_FOREACH (FCurve *, fcu, list) {
/* Check if this F-Curve doesn't belong to a muted group. */
if ((fcu->grp != NULL) && (fcu->grp->flag & AGRP_MUTED)) {
continue;
@@ -1095,7 +1095,7 @@ static void nlaeval_free(NlaEvalData *nlaeval)
nlaeval_snapshot_free_data(&nlaeval->eval_snapshot);
/* Delete channels. */
- for (NlaEvalChannel *nec = nlaeval->channels.first; nec; nec = nec->next) {
+ LISTBASE_FOREACH (NlaEvalChannel *, nec, &nlaeval->channels) {
nlaevalchan_free_data(nec);
}
@@ -1954,7 +1954,7 @@ void nladata_flush_channels(PointerRNA *ptr,
}
/* for each channel with accumulated values, write its value on the property it affects */
- for (NlaEvalChannel *nec = channels->channels.first; nec; nec = nec->next) {
+ LISTBASE_FOREACH (NlaEvalChannel *, nec, &channels->channels) {
NlaEvalChannelSnapshot *nec_snapshot = nlaeval_snapshot_find_channel(snapshot, nec);
PathResolvedRNA rna = {nec->key.ptr, nec->key.prop, -1};
@@ -1985,7 +1985,7 @@ static void nla_eval_domain_action(PointerRNA *ptr,
return;
}
- for (FCurve *fcu = act->curves.first; fcu; fcu = fcu->next) {
+ LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
/* check if this curve should be skipped */
if (fcu->flag & (FCURVE_MUTED | FCURVE_DISABLED)) {
continue;
@@ -2020,7 +2020,7 @@ static void nla_eval_domain_strips(PointerRNA *ptr,
ListBase *strips,
GSet *touched_actions)
{
- for (NlaStrip *strip = strips->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (NlaStrip *, strip, strips) {
/* check strip's action */
if (strip->act) {
nla_eval_domain_action(ptr, channels, strip->act, touched_actions);
@@ -2044,7 +2044,7 @@ static void animsys_evaluate_nla_domain(PointerRNA *ptr, NlaEvalData *channels,
}
/* NLA Data - Animation Data for Strips */
- for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
+ LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
/* solo and muting are mutually exclusive... */
if (adt->flag & ADT_NLA_SOLO_TRACK) {
/* skip if there is a solo track, but this isn't it */
@@ -2430,7 +2430,7 @@ bool BKE_animsys_nla_remap_keyframe_values(struct NlaKeyframingContext *context,
*/
void BKE_animsys_free_nla_keyframing_context_cache(struct ListBase *cache)
{
- for (NlaKeyframingContext *ctx = cache->first; ctx; ctx = ctx->next) {
+ LISTBASE_FOREACH (NlaKeyframingContext *, ctx, cache) {
MEM_SAFE_FREE(ctx->eval_strip);
nlaeval_free(&ctx->nla_channels);
}
@@ -2738,7 +2738,7 @@ void BKE_animsys_update_driver_array(ID *id)
adt->driver_array = MEM_mallocN(sizeof(FCurve *) * num_drivers, "adt->driver_array");
int driver_index = 0;
- for (FCurve *fcu = adt->drivers.first; fcu; fcu = fcu->next) {
+ LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
adt->driver_array[driver_index++] = fcu;
}
}
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index b8d0f8c8c92..daf364432f4 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -190,7 +190,7 @@ bArmature *BKE_armature_from_object(Object *ob)
int BKE_armature_bonelist_count(ListBase *lb)
{
int i = 0;
- for (Bone *bone = lb->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, lb) {
i += 1 + BKE_armature_bonelist_count(&bone->childbase);
}
@@ -303,7 +303,7 @@ static void armature_transform_recurse(ListBase *bonebase,
const Bone *bone_parent,
const float arm_mat_parent_inv[4][4])
{
- for (Bone *bone = bonebase->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, bonebase) {
/* Store the initial bone roll in a matrix, this is needed even for child bones
* so any change in head/tail doesn't cause the roll to change.
@@ -424,7 +424,7 @@ Bone *BKE_armature_find_bone_name(bArmature *arm, const char *name)
static void armature_bone_from_name_insert_recursive(GHash *bone_hash, ListBase *lb)
{
- for (Bone *bone = lb->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, lb) {
BLI_ghash_insert(bone_hash, bone->name, bone);
armature_bone_from_name_insert_recursive(bone_hash, &bone->childbase);
}
@@ -474,7 +474,7 @@ bool BKE_armature_bone_flag_test_recursive(const Bone *bone, int flag)
static void armature_refresh_layer_used_recursive(bArmature *arm, ListBase *bones)
{
- for (Bone *bone = bones->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, bones) {
arm->layer_used |= bone->layer;
armature_refresh_layer_used_recursive(arm, &bone->childbase);
}
@@ -2701,7 +2701,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int
*/
void BKE_pose_clear_pointers(bPose *pose)
{
- for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
pchan->bone = NULL;
pchan->child = NULL;
}
@@ -2709,7 +2709,7 @@ void BKE_pose_clear_pointers(bPose *pose)
void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose)
{
- for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
pchan->bone = BKE_armature_find_bone_name(armature, pchan->name);
}
}
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 70ab52828f2..b3a4de02451 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -182,7 +182,7 @@ static void userdef_free_keymaps(UserDef *userdef)
{
for (wmKeyMap *km = userdef->user_keymaps.first, *km_next; km; km = km_next) {
km_next = km->next;
- for (wmKeyMapDiffItem *kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) {
+ LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &km->diff_items) {
if (kmdi->add_item) {
keymap_item_free(kmdi->add_item);
MEM_freeN(kmdi->add_item);
@@ -193,7 +193,7 @@ static void userdef_free_keymaps(UserDef *userdef)
}
}
- for (wmKeyMapItem *kmi = km->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &km->items) {
keymap_item_free(kmi);
}
@@ -250,7 +250,7 @@ void BKE_blender_userdef_data_free(UserDef *userdef, bool clear_fonts)
userdef_free_addons(userdef);
if (clear_fonts) {
- for (uiFont *font = userdef->uifonts.first; font; font = font->next) {
+ LISTBASE_FOREACH (uiFont *, font, &userdef->uifonts) {
BLF_unload_id(font->blf_id);
}
BLF_default_set(-1);
diff --git a/source/blender/blenkernel/intern/blender_user_menu.c b/source/blender/blenkernel/intern/blender_user_menu.c
index ad34ef03e04..edd89357fd5 100644
--- a/source/blender/blenkernel/intern/blender_user_menu.c
+++ b/source/blender/blenkernel/intern/blender_user_menu.c
@@ -38,7 +38,7 @@
bUserMenu *BKE_blender_user_menu_find(ListBase *lb, char space_type, const char *context)
{
- for (bUserMenu *um = lb->first; um; um = um->next) {
+ LISTBASE_FOREACH (bUserMenu *, um, lb) {
if ((space_type == um->space_type) && (STREQ(context, um->context))) {
return um;
}
diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c
index 6bf47a8c280..d862132480a 100644
--- a/source/blender/blenkernel/intern/blendfile.c
+++ b/source/blender/blenkernel/intern/blendfile.c
@@ -345,7 +345,7 @@ static void setup_app_data(bContext *C,
wmWindowManager *wm = bmain->wm.first;
if (wm) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->scene && win->scene != curscene) {
BKE_scene_set_background(bmain, win->scene);
}
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 323bb597127..71a2b6f703a 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -912,7 +912,7 @@ static Object *camera_multiview_advanced(const Scene *scene, Object *camera, con
name[0] = '\0';
/* we need to take the better match, thus the len_suffix_max test */
- for (const SceneRenderView *srv = scene->r.views.first; srv; srv = srv->next) {
+ LISTBASE_FOREACH (const SceneRenderView *, srv, &scene->r.views) {
const int len_suffix = strlen(srv->suffix);
if ((len_suffix < len_suffix_max) || (len_name < len_suffix)) {
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index d39df4cc6a3..83a6949430e 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -106,10 +106,10 @@ static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, cons
BLI_listbase_clear(&collection_dst->children);
BLI_listbase_clear(&collection_dst->parents);
- for (CollectionChild *child = collection_src->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection_src->children) {
collection_child_add(collection_dst, child->collection, flag, false);
}
- for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection_src->gobject) {
collection_object_add(bmain, collection_dst, cob->ob, flag, false);
}
}
@@ -223,9 +223,8 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
}
else {
/* Link child collections into parent collection. */
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
- for (CollectionParent *cparent = collection->parents.first; cparent;
- cparent = cparent->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
+ LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
Collection *parent = cparent->collection;
collection_child_add(parent, child->collection, 0, true);
}
@@ -234,8 +233,7 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
CollectionObject *cob = collection->gobject.first;
while (cob != NULL) {
/* Link child object into parent collections. */
- for (CollectionParent *cparent = collection->parents.first; cparent;
- cparent = cparent->next) {
+ LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
Collection *parent = cparent->collection;
collection_object_add(bmain, parent, cob->ob, 0, true);
}
@@ -305,7 +303,7 @@ static Collection *collection_duplicate_recursive(Main *bmain,
if (do_objects) {
/* We can loop on collection_old's objects, that list is currently identical the collection_new
* objects, and won't be changed here. */
- for (CollectionObject *cob = collection_old->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection_old->gobject) {
Object *ob_old = cob->ob;
Object *ob_new = (Object *)ob_old->id.newid;
@@ -321,7 +319,7 @@ static Collection *collection_duplicate_recursive(Main *bmain,
/* We can loop on collection_old's children,
* that list is currently identical the collection_new' children, and won't be changed here. */
- for (CollectionChild *child = collection_old->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection_old->children) {
Collection *child_collection_old = child->collection;
collection_duplicate_recursive(
@@ -440,7 +438,7 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i
{
int child_restrict = collection->flag | parent_restrict;
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
Base *base = BLI_findptr(lb, cob->ob, offsetof(Base, object));
if (base == NULL) {
@@ -460,7 +458,7 @@ static void collection_object_cache_fill(ListBase *lb, Collection *collection, i
}
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
collection_object_cache_fill(lb, child->collection, child_restrict);
}
}
@@ -487,7 +485,7 @@ static void collection_object_cache_free(Collection *collection)
collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
BLI_freelistN(&collection->object_cache);
- for (CollectionParent *parent = collection->parents.first; parent; parent = parent->next) {
+ LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) {
collection_object_cache_free(parent->collection);
}
}
@@ -645,8 +643,7 @@ static void collection_tag_update_parent_recursive(Main *bmain,
DEG_id_tag_update_ex(bmain, &collection->id, flag);
- for (CollectionParent *collection_parent = collection->parents.first; collection_parent;
- collection_parent = collection_parent->next) {
+ LISTBASE_FOREACH (CollectionParent *, collection_parent, &collection->parents) {
if (collection_parent->collection->flag & COLLECTION_IS_MASTER) {
/* We don't care about scene/master collection here. */
continue;
@@ -952,7 +949,7 @@ bool BKE_collection_is_in_scene(Collection *collection)
return true;
}
- for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) {
+ LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
if (BKE_collection_is_in_scene(cparent->collection)) {
return true;
}
@@ -977,7 +974,7 @@ bool BKE_collection_find_cycle(Collection *new_ancestor, Collection *collection)
return true;
}
- for (CollectionParent *parent = new_ancestor->parents.first; parent; parent = parent->next) {
+ LISTBASE_FOREACH (CollectionParent *, parent, &new_ancestor->parents) {
if (BKE_collection_find_cycle(parent->collection, collection)) {
return true;
}
@@ -993,7 +990,7 @@ static CollectionChild *collection_find_child(Collection *parent, Collection *co
static bool collection_find_child_recursive(Collection *parent, Collection *collection)
{
- for (CollectionChild *child = parent->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &parent->children) {
if (child->collection == collection) {
return true;
}
@@ -1168,7 +1165,7 @@ static Collection *collection_from_index_recursive(Collection *collection,
(*index_current)++;
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
Collection *nested = collection_from_index_recursive(child->collection, index, index_current);
if (nested != NULL) {
return nested;
@@ -1197,7 +1194,7 @@ static bool collection_objects_select(ViewLayer *view_layer, Collection *collect
return false;
}
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
if (base) {
@@ -1216,7 +1213,7 @@ static bool collection_objects_select(ViewLayer *view_layer, Collection *collect
}
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
if (collection_objects_select(view_layer, collection, deselect)) {
changed = true;
}
@@ -1289,8 +1286,7 @@ bool BKE_collection_move(Main *bmain,
GHash *view_layer_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
view_layer, collection);
@@ -1352,7 +1348,7 @@ static void scene_collection_callback(Collection *collection,
{
callback(collection, data);
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
scene_collection_callback(child->collection, callback, data);
}
}
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 9230746cd1d..7cc40007e26 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -1380,7 +1380,7 @@ Object **BKE_collision_objects_create(Depsgraph *depsgraph,
int num = 0;
Object **objects = MEM_callocN(sizeof(Object *) * maxnum, __func__);
- for (CollisionRelation *relation = relations->first; relation; relation = relation->next) {
+ LISTBASE_FOREACH (CollisionRelation *, relation, relations) {
/* Get evaluated object. */
Object *ob = (Object *)DEG_get_evaluated_id(depsgraph, &relation->ob->id);
@@ -1418,7 +1418,7 @@ ListBase *BKE_collider_cache_create(Depsgraph *depsgraph, Object *self, Collecti
return NULL;
}
- for (CollisionRelation *relation = relations->first; relation; relation = relation->next) {
+ LISTBASE_FOREACH (CollisionRelation *, relation, relations) {
/* Get evaluated object. */
Object *ob = (Object *)DEG_get_evaluated_id(depsgraph, &relation->ob->id);
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 28ce62c3de2..c91bf4e7f5b 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -2513,7 +2513,7 @@ static void armdef_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ
/* Process all targets. This can't use ct->matrix, as armdef_get_tarmat is not
* called in solve for efficiency because the constraint needs bone data anyway. */
- for (bConstraintTarget *ct = targets->first; ct; ct = ct->next) {
+ LISTBASE_FOREACH (bConstraintTarget *, ct, targets) {
if (ct->weight <= 0.0f) {
continue;
}
@@ -5497,7 +5497,7 @@ void BKE_constraints_active_set(ListBase *list, bConstraint *con)
static bConstraint *constraint_list_find_from_target(ListBase *constraints, bConstraintTarget *tgt)
{
- for (bConstraint *con = constraints->first; con; con = con->next) {
+ LISTBASE_FOREACH (bConstraint *, con, constraints) {
ListBase *targets = NULL;
if (con->type == CONSTRAINT_TYPE_PYTHON) {
@@ -5531,7 +5531,7 @@ bConstraint *BKE_constraint_find_from_target(Object *ob,
}
if (ob->pose != NULL) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
result = constraint_list_find_from_target(&pchan->constraints, tgt);
if (result != NULL) {
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 51912e3375a..5b463059f18 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -4612,7 +4612,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
void BKE_curve_nurbs_vert_coords_get(ListBase *lb, float (*vert_coords)[3], int vert_len)
{
float *co = vert_coords[0];
- for (Nurb *nu = lb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, lb) {
if (nu->type == CU_BEZIER) {
BezTriple *bezt = nu->bezt;
for (int i = 0; i < nu->pntsu; i++, bezt++) {
@@ -4692,7 +4692,7 @@ void BKE_curve_nurbs_vert_coords_apply(ListBase *lb,
{
const float *co = vert_coords[0];
- for (Nurb *nu = lb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, lb) {
if (nu->type == CU_BEZIER) {
BezTriple *bezt = nu->bezt;
@@ -4730,7 +4730,7 @@ float (*BKE_curve_nurbs_key_vert_coords_alloc(ListBase *lb, float *key, int *r_v
float(*cos)[3] = MEM_malloc_arrayN(vert_len, sizeof(*cos), __func__);
float *co = cos[0];
- for (Nurb *nu = lb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, lb) {
if (nu->type == CU_BEZIER) {
BezTriple *bezt = nu->bezt;
@@ -5168,7 +5168,7 @@ bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
use_radius = false;
}
/* Do bounding box based on splines. */
- for (Nurb *nu = nurb_lb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurb_lb) {
BKE_nurb_minmax(nu, use_radius, min, max);
}
const bool result = (BLI_listbase_is_empty(nurb_lb) == false);
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 984a7a12b94..e1e818a5a34 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -247,7 +247,7 @@ ListBase *BKE_effector_relations_create(Depsgraph *depsgraph,
add_effector_relation(relations, ob, NULL, ob->pd);
}
- for (ParticleSystem *psys = ob->particlesystem.first; psys; psys = psys->next) {
+ LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
ParticleSettings *part = psys->part;
if (psys_check_enabled(ob, psys, for_render)) {
@@ -286,7 +286,7 @@ ListBase *BKE_effectors_create(Depsgraph *depsgraph,
return NULL;
}
- for (EffectorRelation *relation = relations->first; relation; relation = relation->next) {
+ LISTBASE_FOREACH (EffectorRelation *, relation, relations) {
/* Get evaluated object. */
Object *ob = (Object *)DEG_get_evaluated_id(depsgraph, &relation->ob->id);
@@ -329,7 +329,7 @@ ListBase *BKE_effectors_create(Depsgraph *depsgraph,
void BKE_effectors_free(ListBase *lb)
{
if (lb) {
- for (EffectorCache *eff = lb->first; eff; eff = eff->next) {
+ LISTBASE_FOREACH (EffectorCache *, eff, lb) {
if (eff->guide_data) {
MEM_freeN(eff->guide_data);
}
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index fbca09001d6..439992a4113 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1944,7 +1944,7 @@ void driver_variables_copy(ListBase *dst_vars, const ListBase *src_vars)
BLI_assert(BLI_listbase_is_empty(dst_vars));
BLI_duplicatelist(dst_vars, src_vars);
- for (DriverVar *dvar = dst_vars->first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, dst_vars) {
/* need to go over all targets so that we don't leave any dangling paths */
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* make a copy of target's rna path if available */
@@ -2167,7 +2167,7 @@ static ExprPyLike_Parsed *driver_compile_simple_expr_impl(ChannelDriver *driver)
names[VAR_INDEX_FRAME] = "frame";
- for (DriverVar *dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
names[i++] = dvar->name;
}
@@ -2192,7 +2192,7 @@ static bool driver_evaluate_simple_expr(ChannelDriver *driver,
vars[VAR_INDEX_FRAME] = time;
- for (DriverVar *dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
vars[i++] = driver_get_variable_value(driver, dvar);
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 1d5a908e226..c85283e3653 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -1358,7 +1358,7 @@ uint evaluate_fmodifiers_storage_size_per_modifier(ListBase *modifiers)
uint max_size = 0;
- for (FModifier *fcm = modifiers->first; fcm; fcm = fcm->next) {
+ LISTBASE_FOREACH (FModifier *, fcm, modifiers) {
const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm);
if (fmi == NULL) {
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index b2fc91fd0a6..a0fa07f4a41 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -644,7 +644,7 @@ bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src)
/* copy strokes */
BLI_listbase_clear(&gpf_dst->strokes);
- for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* make copy of source stroke */
gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
BLI_addtail(&gpf_dst->strokes, gps_dst);
@@ -665,7 +665,7 @@ void BKE_gpencil_frame_copy_strokes(bGPDframe *gpf_src, struct bGPDframe *gpf_ds
/* copy strokes */
BLI_listbase_clear(&gpf_dst->strokes);
- for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* make copy of source stroke */
gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
BLI_addtail(&gpf_dst->strokes, gps_dst);
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 6bdcc9cfbcb..874672f4a73 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -1685,7 +1685,7 @@ static Collection *gpencil_get_parent_collection(Scene *scene, Object *ob)
{
Collection *mycol = NULL;
FOREACH_SCENE_COLLECTION_BEGIN (scene, collection) {
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
if ((mycol == NULL) && (cob->ob == ob)) {
mycol = collection;
}
@@ -1976,7 +1976,7 @@ void BKE_gpencil_convert_curve(Main *bmain,
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_ADD_COPY);
/* Read all splines of the curve and create a stroke for each. */
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
gpencil_convert_spline(bmain, ob_gp, ob_cu, gpencil_lines, only_stroke, gpf, nu);
}
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index 554b8d93db3..5530a126ffc 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -800,7 +800,7 @@ void IDP_RelinkProperty(struct IDProperty *prop)
switch (prop->type) {
case IDP_GROUP: {
- for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
+ LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
IDP_RelinkProperty(loop);
}
break;
diff --git a/source/blender/blenkernel/intern/idprop_utils.c b/source/blender/blenkernel/intern/idprop_utils.c
index 629fecf42f4..f8a1113f69b 100644
--- a/source/blender/blenkernel/intern/idprop_utils.c
+++ b/source/blender/blenkernel/intern/idprop_utils.c
@@ -167,7 +167,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro
}
case IDP_GROUP: {
STR_APPEND_STR("{");
- for (const IDProperty *subprop = prop->data.group.first; subprop; subprop = subprop->next) {
+ LISTBASE_FOREACH (const IDProperty *, subprop, &prop->data.group) {
if (subprop != prop->data.group.first) {
STR_APPEND_STR(", ");
}
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 0fb70869ac0..f58e7c06d7f 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -3101,7 +3101,7 @@ static void image_walk_ntree_all_users(
{
switch (ntree->type) {
case NTREE_SHADER:
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->id) {
if (node->type == SH_NODE_TEX_IMAGE) {
NodeTexImage *tex = node->storage;
@@ -3117,7 +3117,7 @@ static void image_walk_ntree_all_users(
}
break;
case NTREE_TEXTURE:
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->id && node->type == TEX_NODE_IMAGE) {
Image *ima = (Image *)node->id;
ImageUser *iuser = node->storage;
@@ -3126,7 +3126,7 @@ static void image_walk_ntree_all_users(
}
break;
case NTREE_COMPOSIT:
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->id && node->type == CMP_NODE_IMAGE) {
Image *ima = (Image *)node->id;
ImageUser *iuser = node->storage;
@@ -3189,17 +3189,17 @@ static void image_walk_id_all_users(
}
case ID_CA: {
Camera *cam = (Camera *)id;
- for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
callback(bgpic->ima, NULL, &bgpic->iuser, customdata);
}
break;
}
case ID_WM: {
wmWindowManager *wm = (wmWindowManager *)id;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacetype == SPACE_IMAGE) {
SpaceImage *sima = area->spacedata.first;
callback(sima->image, NULL, &sima->iuser, customdata);
@@ -3761,7 +3761,7 @@ static void image_init_multilayer_multiview(Image *ima, RenderResult *rr)
BKE_image_free_views(ima);
if (rr) {
- for (RenderView *rv = rr->views.first; rv; rv = rv->next) {
+ LISTBASE_FOREACH (RenderView *, rv, &rr->views) {
ImageView *iv = MEM_callocN(sizeof(ImageView), "Viewer Image View");
STRNCPY(iv->name, rv->name);
BLI_addtail(&ima->views, iv);
diff --git a/source/blender/blenkernel/intern/keyconfig.c b/source/blender/blenkernel/intern/keyconfig.c
index 84f48441cf9..ada5fc5b6aa 100644
--- a/source/blender/blenkernel/intern/keyconfig.c
+++ b/source/blender/blenkernel/intern/keyconfig.c
@@ -209,7 +209,7 @@ void BKE_keyconfig_pref_filter_items(struct UserDef *userdef,
bool (*filter_fn)(wmKeyMapItem *kmi, void *user_data),
void *user_data)
{
- for (wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) {
+ LISTBASE_FOREACH (wmKeyMap *, keymap, &userdef->user_keymaps) {
BKE_keyconfig_keymap_filter_item(keymap, params, filter_fn, user_data);
}
}
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index ffa1eecc87b..d8f0bda8c22 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -83,7 +83,7 @@ static void layer_collection_free(ViewLayer *view_layer, LayerCollection *lc)
view_layer->active_collection = NULL;
}
- for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) {
layer_collection_free(view_layer, nlc);
}
@@ -109,8 +109,7 @@ static Base *object_base_new(Object *ob)
* none linked to the workspace yet. */
ViewLayer *BKE_view_layer_default_view(const Scene *scene)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
if (!(view_layer->flag & VIEW_LAYER_RENDER)) {
return view_layer;
}
@@ -123,8 +122,7 @@ ViewLayer *BKE_view_layer_default_view(const Scene *scene)
/* Returns the default view layer to render if we need to render just one. */
ViewLayer *BKE_view_layer_default_render(const Scene *scene)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
if (view_layer->flag & VIEW_LAYER_RENDER) {
return view_layer;
}
@@ -137,8 +135,7 @@ ViewLayer *BKE_view_layer_default_render(const Scene *scene)
/* Returns view layer with matching name, or NULL if not found. */
ViewLayer *BKE_view_layer_find(const Scene *scene, const char *layer_name)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
if (STREQ(view_layer->name, layer_name)) {
return view_layer;
}
@@ -262,12 +259,12 @@ void BKE_view_layer_free_ex(ViewLayer *view_layer, const bool do_id_user)
BLI_ghash_free(view_layer->object_bases_hash, NULL, NULL);
}
- for (LayerCollection *lc = view_layer->layer_collections.first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, &view_layer->layer_collections) {
layer_collection_free(view_layer, lc);
}
BLI_freelistN(&view_layer->layer_collections);
- for (ViewLayerEngineData *sled = view_layer->drawdata.first; sled; sled = sled->next) {
+ LISTBASE_FOREACH (ViewLayerEngineData *, sled, &view_layer->drawdata) {
if (sled->storage) {
if (sled->free) {
sled->free(sled->storage);
@@ -295,7 +292,7 @@ void BKE_view_layer_free_ex(ViewLayer *view_layer, const bool do_id_user)
*/
void BKE_view_layer_selected_objects_tag(ViewLayer *view_layer, const int tag)
{
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if ((base->flag & BASE_SELECTED) != 0) {
base->object->flag |= tag;
}
@@ -307,7 +304,7 @@ void BKE_view_layer_selected_objects_tag(ViewLayer *view_layer, const int tag)
static bool find_scene_collection_in_scene_collections(ListBase *lb, const LayerCollection *lc)
{
- for (LayerCollection *lcn = lb->first; lcn; lcn = lcn->next) {
+ LISTBASE_FOREACH (LayerCollection *, lcn, lb) {
if (lcn == lc) {
return true;
}
@@ -327,7 +324,7 @@ static bool find_scene_collection_in_scene_collections(ListBase *lb, const Layer
*/
Object *BKE_view_layer_camera_find(ViewLayer *view_layer)
{
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->type == OB_CAMERA) {
return base->object;
}
@@ -341,8 +338,7 @@ Object *BKE_view_layer_camera_find(ViewLayer *view_layer)
*/
ViewLayer *BKE_view_layer_find_from_collection(const Scene *scene, LayerCollection *lc)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
if (find_scene_collection_in_scene_collections(&view_layer->layer_collections, lc)) {
return view_layer;
}
@@ -364,7 +360,7 @@ static void view_layer_bases_hash_create(ViewLayer *view_layer)
view_layer->object_bases_hash = BLI_ghash_new(
BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object) {
BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
}
@@ -455,7 +451,7 @@ void BKE_view_layer_copy_data(Scene *scene_dst,
/* Copy layer collections and object bases. */
/* Inline 'BLI_duplicatelist' and update the active base. */
BLI_listbase_clear(&view_layer_dst->object_bases);
- for (Base *base_src = view_layer_src->object_bases.first; base_src; base_src = base_src->next) {
+ LISTBASE_FOREACH (Base *, base_src, &view_layer_src->object_bases) {
Base *base_dst = MEM_dupallocN(base_src);
BLI_addtail(&view_layer_dst->object_bases, base_dst);
if (view_layer_src->basact == base_src) {
@@ -506,7 +502,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
/* WM can be missing on startup. */
wmWindowManager *wm = bmain->wm.first;
if (wm) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->scene == scene && STREQ(win->view_layer_name, oldname)) {
STRNCPY(win->view_layer_name, view_layer->name);
}
@@ -524,7 +520,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con
*/
static LayerCollection *collection_from_index(ListBase *lb, const int number, int *i)
{
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
if (*i == number) {
return lc;
}
@@ -532,7 +528,7 @@ static LayerCollection *collection_from_index(ListBase *lb, const int number, in
(*i)++;
}
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
LayerCollection *lc_nested = collection_from_index(&lc->layer_collections, number, i);
if (lc_nested) {
return lc_nested;
@@ -635,7 +631,7 @@ LayerCollection *BKE_layer_collection_activate_parent(ViewLayer *view_layer, Lay
static int collection_count(ListBase *lb)
{
int i = 0;
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
i += collection_count(&lc->layer_collections) + 1;
}
return i;
@@ -655,7 +651,7 @@ int BKE_layer_collection_count(ViewLayer *view_layer)
*/
static int index_from_collection(ListBase *lb, const LayerCollection *lc, int *i)
{
- for (LayerCollection *lcol = lb->first; lcol; lcol = lcol->next) {
+ LISTBASE_FOREACH (LayerCollection *, lcol, lb) {
if (lcol == lc) {
return *i;
}
@@ -663,7 +659,7 @@ static int index_from_collection(ListBase *lb, const LayerCollection *lc, int *i
(*i)++;
}
- for (LayerCollection *lcol = lb->first; lcol; lcol = lcol->next) {
+ LISTBASE_FOREACH (LayerCollection *, lcol, lb) {
int i_nested = index_from_collection(&lcol->layer_collections, lc, i);
if (i_nested != -1) {
return i_nested;
@@ -733,7 +729,7 @@ static short layer_collection_sync(ViewLayer *view_layer,
ListBase new_lb_layer = {NULL, NULL};
short runtime_flag = 0;
- for (const CollectionChild *child = lb_scene->first; child; child = child->next) {
+ LISTBASE_FOREACH (const CollectionChild *, child, lb_scene) {
Collection *collection = child->collection;
LayerCollection *lc = BLI_findptr(lb_layer, collection, offsetof(LayerCollection, collection));
@@ -792,7 +788,7 @@ static short layer_collection_sync(ViewLayer *view_layer,
}
/* Sync objects, except if collection was excluded. */
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
if (cob->ob == NULL) {
continue;
}
@@ -877,7 +873,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
}
/* Clear visible and selectable flags to be reset. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->flag &= ~g_base_collection_flags;
base->flag_from_collection &= ~g_base_collection_flags;
}
@@ -898,7 +894,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
~(0));
/* Any remaining object bases are to be removed. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (view_layer->basact == base) {
view_layer->basact = NULL;
}
@@ -911,7 +907,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
BLI_freelistN(&view_layer->object_bases);
view_layer->object_bases = new_object_bases;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
BKE_base_eval_flags(base);
}
@@ -927,8 +923,7 @@ void BKE_layer_collection_sync(const Scene *scene, ViewLayer *view_layer)
void BKE_scene_collection_sync(const Scene *scene)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
BKE_layer_collection_sync(scene, view_layer);
}
}
@@ -951,8 +946,7 @@ void BKE_main_collection_sync_remap(const Main *bmain)
/* TODO: try to make this faster */
for (const Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
MEM_SAFE_FREE(view_layer->object_bases_array);
if (view_layer->object_bases_hash) {
@@ -988,7 +982,7 @@ bool BKE_layer_collection_objects_select(ViewLayer *view_layer, LayerCollection
bool changed = false;
if (!(lc->flag & LAYER_COLLECTION_EXCLUDE)) {
- for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
if (base) {
@@ -1008,7 +1002,7 @@ bool BKE_layer_collection_objects_select(ViewLayer *view_layer, LayerCollection
}
}
- for (LayerCollection *iter = lc->layer_collections.first; iter; iter = iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, iter, &lc->layer_collections) {
changed |= BKE_layer_collection_objects_select(view_layer, iter, deselect);
}
@@ -1022,7 +1016,7 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerColle
}
if (!(lc->flag & LAYER_COLLECTION_EXCLUDE)) {
- for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) {
@@ -1031,7 +1025,7 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerColle
}
}
- for (LayerCollection *iter = lc->layer_collections.first; iter; iter = iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, iter, &lc->layer_collections) {
if (BKE_layer_collection_has_selected_objects(view_layer, iter)) {
return true;
}
@@ -1047,8 +1041,7 @@ bool BKE_layer_collection_has_layer_collection(LayerCollection *lc_parent,
return true;
}
- for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, lc_child)) {
return true;
}
@@ -1063,7 +1056,7 @@ void BKE_base_set_visible(Scene *scene, ViewLayer *view_layer, Base *base, bool
{
if (!extend) {
/* Make only one base visible. */
- for (Base *other = view_layer->object_bases.first; other; other = other->next) {
+ LISTBASE_FOREACH (Base *, other, &view_layer->object_bases) {
other->flag |= BASE_HIDDEN;
}
@@ -1134,7 +1127,7 @@ bool BKE_object_is_visible_in_viewport(const struct View3D *v3d, const struct Ob
static void layer_collection_flag_set_recursive(LayerCollection *lc, const int flag)
{
lc->flag |= flag;
- for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) {
layer_collection_flag_set_recursive(lc_iter, flag);
}
}
@@ -1142,7 +1135,7 @@ static void layer_collection_flag_set_recursive(LayerCollection *lc, const int f
static void layer_collection_flag_unset_recursive(LayerCollection *lc, const int flag)
{
lc->flag &= ~flag;
- for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) {
layer_collection_flag_unset_recursive(lc_iter, flag);
}
}
@@ -1165,8 +1158,7 @@ void BKE_layer_collection_isolate_global(Scene *scene,
if (!extend) {
/* Hide all collections . */
- for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
layer_collection_flag_set_recursive(lc_iter, LAYER_COLLECTION_HIDE);
}
}
@@ -1177,8 +1169,7 @@ void BKE_layer_collection_isolate_global(Scene *scene,
}
else {
LayerCollection *lc_parent = lc;
- for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) {
lc_parent = lc_iter;
break;
@@ -1188,8 +1179,7 @@ void BKE_layer_collection_isolate_global(Scene *scene,
while (lc_parent != lc) {
lc_parent->flag &= ~LAYER_COLLECTION_HIDE;
- for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) {
lc_parent = lc_iter;
break;
@@ -1210,8 +1200,7 @@ static void layer_collection_local_visibility_set_recursive(LayerCollection *lay
const int local_collections_uuid)
{
layer_collection->local_collections_bits |= local_collections_uuid;
- for (LayerCollection *child = layer_collection->layer_collections.first; child;
- child = child->next) {
+ LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
layer_collection_local_visibility_set_recursive(child, local_collections_uuid);
}
}
@@ -1220,8 +1209,7 @@ static void layer_collection_local_visibility_unset_recursive(LayerCollection *l
const int local_collections_uuid)
{
layer_collection->local_collections_bits &= ~local_collections_uuid;
- for (LayerCollection *child = layer_collection->layer_collections.first; child;
- child = child->next) {
+ LISTBASE_FOREACH (LayerCollection *, child, &layer_collection->layer_collections) {
layer_collection_local_visibility_unset_recursive(child, local_collections_uuid);
}
}
@@ -1236,8 +1224,7 @@ static void layer_collection_local_sync(ViewLayer *view_layer,
}
if (visible) {
- for (CollectionObject *cob = layer_collection->collection->gobject.first; cob;
- cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &layer_collection->collection->gobject) {
BLI_assert(cob->ob);
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
base->local_collections_bits |= local_collections_uuid;
@@ -1256,7 +1243,7 @@ void BKE_layer_collection_local_sync(ViewLayer *view_layer, View3D *v3d)
const unsigned short local_collections_uuid = v3d->local_collections_uuid;
/* Reset flags and set the bases visible by default. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->local_collections_bits &= ~local_collections_uuid;
}
@@ -1280,8 +1267,7 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer,
if (!extend) {
/* Hide all collections. */
- for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
layer_collection_local_visibility_unset_recursive(lc_iter, v3d->local_collections_uuid);
}
}
@@ -1292,8 +1278,7 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer,
}
else {
LayerCollection *lc_parent = lc;
- for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) {
lc_parent = lc_iter;
break;
@@ -1303,8 +1288,7 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer,
while (lc_parent != lc) {
lc_parent->local_collections_bits |= v3d->local_collections_uuid;
- for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, lc)) {
lc_parent = lc_iter;
break;
@@ -1322,12 +1306,12 @@ void BKE_layer_collection_isolate_local(ViewLayer *view_layer,
static void layer_collection_bases_show_recursive(ViewLayer *view_layer, LayerCollection *lc)
{
if ((lc->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
- for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
base->flag &= ~BASE_HIDDEN;
}
}
- for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) {
layer_collection_bases_show_recursive(view_layer, lc_iter);
}
}
@@ -1335,12 +1319,12 @@ static void layer_collection_bases_show_recursive(ViewLayer *view_layer, LayerCo
static void layer_collection_bases_hide_recursive(ViewLayer *view_layer, LayerCollection *lc)
{
if ((lc->flag & LAYER_COLLECTION_EXCLUDE) == 0) {
- for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
base->flag |= BASE_HIDDEN;
}
}
- for (LayerCollection *lc_iter = lc->layer_collections.first; lc_iter; lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc->layer_collections) {
layer_collection_bases_hide_recursive(view_layer, lc_iter);
}
}
@@ -1384,7 +1368,7 @@ static LayerCollection *find_layer_collection_by_scene_collection(LayerCollectio
return lc;
}
- for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) {
LayerCollection *found = find_layer_collection_by_scene_collection(nlc, collection);
if (found) {
return found;
@@ -1425,8 +1409,7 @@ bool BKE_view_layer_has_collection(ViewLayer *view_layer, const Collection *coll
*/
bool BKE_scene_has_object(Scene *scene, Object *ob)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (base) {
return true;
@@ -1768,7 +1751,7 @@ static void layer_eval_view_layer(struct Depsgraph *depsgraph,
view_layer->object_bases_array = MEM_malloc_arrayN(
num_object_bases, sizeof(Base *), "view_layer->object_bases_array");
int base_index = 0;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
view_layer->object_bases_array[base_index++] = base;
}
}
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 21e27784684..286ee4a8723 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -901,7 +901,7 @@ void BKE_main_id_flag_all(Main *bmain, const int flag, const bool value)
void BKE_main_id_repair_duplicate_names_listbase(ListBase *lb)
{
int lb_len = 0;
- for (ID *id = lb->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lb) {
if (id->lib == NULL) {
lb_len += 1;
}
@@ -914,7 +914,7 @@ void BKE_main_id_repair_duplicate_names_listbase(ListBase *lb)
ID **id_array = MEM_mallocN(sizeof(*id_array) * lb_len, __func__);
GSet *gset = BLI_gset_str_new_ex(__func__, lb_len);
int i = 0;
- for (ID *id = lb->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lb) {
if (id->lib == NULL) {
id_array[i] = id;
i++;
@@ -2218,14 +2218,14 @@ void BKE_id_ordered_list(ListBase *ordered_lb, const ListBase *lb)
{
BLI_listbase_clear(ordered_lb);
- for (ID *id = lb->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lb) {
BLI_addtail(ordered_lb, BLI_genericNodeN(id));
}
BLI_listbase_sort(ordered_lb, id_order_compare);
int num = 0;
- for (LinkData *link = ordered_lb->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, ordered_lb) {
int *order = id_order_get(link->data);
if (order) {
*order = num++;
@@ -2250,7 +2250,7 @@ void BKE_id_reorder(const ListBase *lb, ID *id, ID *relative, bool after)
if (after) {
/* Insert after. */
- for (ID *other = lb->first; other; other = other->next) {
+ LISTBASE_FOREACH (ID *, other, lb) {
int *order = id_order_get(other);
if (*order > relative_order) {
(*order)++;
@@ -2261,7 +2261,7 @@ void BKE_id_reorder(const ListBase *lb, ID *id, ID *relative, bool after)
}
else {
/* Insert before. */
- for (ID *other = lb->first; other; other = other->next) {
+ LISTBASE_FOREACH (ID *, other, lb) {
int *order = id_order_get(other);
if (*order < relative_order) {
(*order)--;
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 42d1806a41a..5b75b8ac181 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -153,7 +153,7 @@ void BKE_lib_override_library_clear(IDOverrideLibrary *override, const bool do_i
BLI_ghash_clear(override->runtime, NULL, NULL);
}
- for (IDOverrideLibraryProperty *op = override->properties.first; op; op = op->next) {
+ LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &override->properties) {
lib_override_library_property_clear(op);
}
BLI_freelistN(&override->properties);
@@ -371,7 +371,7 @@ void lib_override_library_property_clear(IDOverrideLibraryProperty *op)
MEM_freeN(op->rna_path);
- for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop; opop = opop->next) {
+ LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
lib_override_library_property_operation_clear(opop);
}
BLI_freelistN(&op->operations);
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index 21d7bb137fc..9c0fa33157c 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -182,7 +182,7 @@ static void library_foreach_idproperty_ID_link(LibraryForeachIDData *data,
switch (prop->type) {
case IDP_GROUP: {
- for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
+ LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
library_foreach_idproperty_ID_link(data, loop, flag);
}
break;
@@ -338,7 +338,7 @@ static void library_foreach_bone(LibraryForeachIDData *data, Bone *bone)
{
library_foreach_idproperty_ID_link(data, bone->prop, IDWALK_CB_USER);
- for (Bone *curbone = bone->childbase.first; curbone; curbone = curbone->next) {
+ LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) {
library_foreach_bone(data, curbone);
}
@@ -347,7 +347,7 @@ static void library_foreach_bone(LibraryForeachIDData *data, Bone *bone)
static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBase *lb)
{
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
/* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
* anyway... */
const int cb_flag = (lc->collection != NULL &&
@@ -365,13 +365,13 @@ static void library_foreach_layer_collection(LibraryForeachIDData *data, ListBas
*/
static void library_foreach_collection(LibraryForeachIDData *data, Collection *collection)
{
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
FOREACH_CALLBACK_INVOKE(data, cob->ob, IDWALK_CB_USER);
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
FOREACH_CALLBACK_INVOKE(data, child->collection, IDWALK_CB_NEVER_SELF | IDWALK_CB_USER);
}
- for (CollectionParent *parent = collection->parents.first; parent; parent = parent->next) {
+ LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) {
/* XXX This is very weak. The whole idea of keeping pointers to private IDs is very bad
* anyway... */
const int cb_flag = ((parent->collection != NULL &&
@@ -399,7 +399,7 @@ static void library_foreach_screen_area(LibraryForeachIDData *data, ScrArea *are
{
FOREACH_CALLBACK_INVOKE(data, area->full, IDWALK_CB_NOP);
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
switch (sl->spacetype) {
case SPACE_VIEW3D: {
View3D *v3d = (View3D *)sl;
@@ -678,7 +678,7 @@ static void library_foreach_ID_link(Main *bmain,
CALLBACK_INVOKE(seq->mask, IDWALK_CB_USER);
CALLBACK_INVOKE(seq->sound, IDWALK_CB_USER);
library_foreach_idproperty_ID_link(&data, seq->prop, IDWALK_CB_USER);
- for (SequenceModifierData *smd = seq->modifiers.first; smd; smd = smd->next) {
+ LISTBASE_FOREACH (SequenceModifierData *, smd, &seq->modifiers) {
CALLBACK_INVOKE(smd->mask_id, IDWALK_CB_USER);
}
@@ -699,21 +699,19 @@ static void library_foreach_ID_link(Main *bmain,
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
CALLBACK_INVOKE(view_layer->mat_override, IDWALK_CB_USER);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
CALLBACK_INVOKE(base->object, IDWALK_CB_NOP);
}
library_foreach_layer_collection(&data, &view_layer->layer_collections);
- for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc;
- fmc = fmc->next) {
+ LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
if (fmc->script) {
CALLBACK_INVOKE(fmc->script, IDWALK_CB_NOP);
}
}
- for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls;
- fls = fls->next) {
+ LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
if (fls->group) {
CALLBACK_INVOKE(fls->group, IDWALK_CB_USER);
}
@@ -724,7 +722,7 @@ static void library_foreach_ID_link(Main *bmain,
}
}
- for (TimeMarker *marker = scene->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &scene->markers) {
CALLBACK_INVOKE(marker->camera, IDWALK_CB_NOP);
}
@@ -881,7 +879,7 @@ static void library_foreach_ID_link(Main *bmain,
case ID_AR: {
bArmature *arm = (bArmature *)id;
- for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
library_foreach_bone(&data, bone);
}
break;
@@ -968,7 +966,7 @@ static void library_foreach_ID_link(Main *bmain,
case ID_CA: {
Camera *camera = (Camera *)id;
CALLBACK_INVOKE(camera->dof.focus_object, IDWALK_CB_NOP);
- for (CameraBGImage *bgpic = camera->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &camera->bg_images) {
if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) {
CALLBACK_INVOKE(bgpic->ima, IDWALK_CB_USER);
}
@@ -1100,7 +1098,7 @@ static void library_foreach_ID_link(Main *bmain,
}
}
- for (ParticleDupliWeight *dw = psett->instance_weights.first; dw; dw = dw->next) {
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &psett->instance_weights) {
CALLBACK_INVOKE(dw->ob, IDWALK_CB_NOP);
}
break;
@@ -1195,7 +1193,7 @@ static void library_foreach_ID_link(Main *bmain,
case ID_AC: {
bAction *act = (bAction *)id;
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
CALLBACK_INVOKE(marker->camera, IDWALK_CB_NOP);
}
break;
@@ -1204,7 +1202,7 @@ static void library_foreach_ID_link(Main *bmain,
case ID_WM: {
wmWindowManager *wm = (wmWindowManager *)id;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
CALLBACK_INVOKE(win->scene, IDWALK_CB_USER_ONE);
/* This pointer can be NULL during old files reading, better be safe than sorry. */
@@ -1215,7 +1213,7 @@ static void library_foreach_ID_link(Main *bmain,
BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace);
}
if (data.flag & IDWALK_INCLUDE_UI) {
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
library_foreach_screen_area(&data, area);
}
}
@@ -1227,7 +1225,7 @@ static void library_foreach_ID_link(Main *bmain,
WorkSpace *workspace = (WorkSpace *)id;
ListBase *layouts = BKE_workspace_layouts_get(workspace);
- for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) {
bScreen *screen = BKE_workspace_layout_screen_get(layout);
/* CALLBACK_INVOKE expects an actual pointer, not a variable holding the pointer.
@@ -1280,7 +1278,7 @@ static void library_foreach_ID_link(Main *bmain,
if (data.flag & IDWALK_INCLUDE_UI) {
bScreen *screen = (bScreen *)id;
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
library_foreach_screen_area(&data, area);
}
}
@@ -1710,7 +1708,7 @@ void BKE_library_indirectly_used_data_tag_clear(Main *bmain)
do_loop = false;
while (i--) {
- for (ID *id = lb_array[i]->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lb_array[i]) {
if (id->lib == NULL || id->tag & LIB_TAG_DOIT) {
/* Local or non-indirectly-used ID (so far), no need to check it further. */
continue;
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index bcf4b29ec07..5516e877b10 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1121,7 +1121,7 @@ static bool ntree_foreach_texnode_recursive(bNodeTree *nodetree,
ForEachTexNodeCallback callback,
void *userdata)
{
- for (bNode *node = nodetree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &nodetree->nodes) {
if (node->typeinfo->nclass == NODE_CLASS_TEXTURE &&
node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) {
if (!callback(node, userdata)) {
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index 79e70ad2741..4294d279c36 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -430,9 +430,8 @@ Object *BKE_mball_basis_find(Scene *scene, Object *basis)
BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.');
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == OB_MBALL) && !(base->flag & BASE_FROM_DUPLI)) {
if (ob != bob) {
@@ -463,7 +462,7 @@ bool BKE_mball_minmax_ex(
INIT_MINMAX(min, max);
- for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (const MetaElem *, ml, &mb->elems) {
if ((ml->flag & flag) == flag) {
const float scale_mb = (ml->rad * 0.5f) * scale;
int i;
@@ -493,7 +492,7 @@ bool BKE_mball_minmax(const MetaBall *mb, float min[3], float max[3])
{
INIT_MINMAX(min, max);
- for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (const MetaElem *, ml, &mb->elems) {
minmax_v3v3_v3(min, max, &ml->x);
}
@@ -506,7 +505,7 @@ bool BKE_mball_center_median(const MetaBall *mb, float r_cent[3])
zero_v3(r_cent);
- for (const MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (const MetaElem *, ml, &mb->elems) {
add_v3_v3(r_cent, &ml->x);
total++;
}
@@ -538,7 +537,7 @@ void BKE_mball_transform(MetaBall *mb, const float mat[4][4], const bool do_prop
mat4_to_quat(quat, mat);
- for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) {
mul_m4_v3(mat, &ml->x);
mul_qt_qtqt(ml->quat, quat, ml->quat);
@@ -558,7 +557,7 @@ void BKE_mball_transform(MetaBall *mb, const float mat[4][4], const bool do_prop
void BKE_mball_translate(MetaBall *mb, const float offset[3])
{
- for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) {
add_v3_v3(&ml->x, offset);
}
}
@@ -567,7 +566,7 @@ void BKE_mball_translate(MetaBall *mb, const float offset[3])
int BKE_mball_select_count(const MetaBall *mb)
{
int sel = 0;
- for (const MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (const MetaElem *, ml, mb->editelems) {
if (ml->flag & SELECT) {
sel++;
}
@@ -589,7 +588,7 @@ int BKE_mball_select_count_multi(Base **bases, int bases_len)
bool BKE_mball_select_all(MetaBall *mb)
{
bool changed = false;
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if ((ml->flag & SELECT) == 0) {
ml->flag |= SELECT;
changed = true;
@@ -612,7 +611,7 @@ bool BKE_mball_select_all_multi_ex(Base **bases, int bases_len)
bool BKE_mball_deselect_all(MetaBall *mb)
{
bool changed = false;
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if ((ml->flag & SELECT) != 0) {
ml->flag &= ~SELECT;
changed = true;
@@ -636,7 +635,7 @@ bool BKE_mball_deselect_all_multi_ex(Base **bases, int bases_len)
bool BKE_mball_select_swap(MetaBall *mb)
{
bool changed = false;
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
ml->flag ^= SELECT;
changed = true;
}
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 98a7673c9d5..c3c538f3424 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -113,7 +113,7 @@ static void ntree_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, c
/* Since source nodes and sockets are unique pointers we can put everything in a single map. */
GHash *new_pointers = BLI_ghash_ptr_new(__func__);
- for (const bNode *node_src = ntree_src->nodes.first; node_src; node_src = node_src->next) {
+ LISTBASE_FOREACH (const bNode *, node_src, &ntree_src->nodes) {
bNode *new_node = BKE_node_copy_ex(ntree_dst, node_src, flag_subdata, true);
BLI_ghash_insert(new_pointers, (void *)node_src, new_node);
/* Store mapping to inputs. */
@@ -1634,7 +1634,7 @@ void nodePositionRelative(bNode *from_node,
void nodePositionPropagate(bNode *node)
{
- for (bNodeSocket *nsock = node->inputs.first; nsock; nsock = nsock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, nsock, &node->inputs) {
if (nsock->link != NULL) {
bNodeLink *link = nsock->link;
nodePositionRelative(link->fromnode, link->tonode, link->fromsock, link->tosock);
@@ -2662,7 +2662,7 @@ void ntreeInterfaceTypeUpdate(bNodeTree *ntree)
bNode *ntreeFindType(const bNodeTree *ntree, int type)
{
if (ntree) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == type) {
return node;
}
@@ -3396,7 +3396,7 @@ void ntreeUpdateAllNew(Main *main)
* might have been set in file reading or versioning. */
FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
if (owner_id->tag & LIB_TAG_NEW) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->typeinfo->group_update_func) {
node->typeinfo->group_update_func(ntree, node);
}
@@ -3414,7 +3414,7 @@ void ntreeUpdateAllUsers(Main *main, ID *ngroup)
FOREACH_NODETREE_BEGIN (main, ntree, owner_id) {
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->id == ngroup) {
if (node->typeinfo->group_update_func) {
node->typeinfo->group_update_func(ntree, node);
@@ -4245,7 +4245,7 @@ bool BKE_node_tree_iter_step(struct NodeTreeIterStore *ntreeiter,
void BKE_nodetree_remove_layer_n(bNodeTree *ntree, Scene *scene, const int layer_index)
{
BLI_assert(layer_index != -1);
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_R_LAYERS && (Scene *)node->id == scene) {
if (node->custom1 == layer_index) {
node->custom1 = 0;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 87ac4428594..587dd5be2f2 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -479,7 +479,7 @@ void psys_find_group_weights(ParticleSettings *part)
instance_collection_objects = BKE_collection_object_cache_get(part->instance_collection);
}
- for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
if (dw->ob == NULL) {
Base *base = BLI_findlink(&instance_collection_objects, dw->index);
if (base != NULL) {
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index b1cff53d399..78e7dec9f38 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1839,7 +1839,7 @@ PTCacheID BKE_ptcache_id_find(Object *ob, Scene *scene, PointCache *cache)
ListBase pidlist;
BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR);
- for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) {
+ LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) {
if (pid->cache == cache) {
result = *pid;
break;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 8cbc1ba4d8e..20f7add0c74 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -669,10 +669,9 @@ Scene *BKE_scene_copy(Main *bmain, Scene *sce, int type)
if (type == SCE_COPY_FULL) {
/* Copy Freestyle LineStyle datablocks. */
- for (ViewLayer *view_layer_dst = sce_copy->view_layers.first; view_layer_dst;
- view_layer_dst = view_layer_dst->next) {
- for (FreestyleLineSet *lineset = view_layer_dst->freestyle_config.linesets.first; lineset;
- lineset = lineset->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer_dst, &sce_copy->view_layers) {
+ LISTBASE_FOREACH (
+ FreestyleLineSet *, lineset, &view_layer_dst->freestyle_config.linesets) {
if (lineset->linestyle) {
id_us_min(&lineset->linestyle->id);
BKE_id_copy_ex(
@@ -732,8 +731,7 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
*/
bool BKE_scene_object_find(Scene *scene, Object *ob)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
if (BLI_findptr(&view_layer->object_bases, ob, offsetof(Base, object))) {
return true;
}
@@ -743,9 +741,8 @@ bool BKE_scene_object_find(Scene *scene, Object *ob)
Object *BKE_scene_object_find_by_name(const Scene *scene, const char *name)
{
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (STREQ(base->object->id.name + 2, name)) {
return base->object;
}
@@ -773,9 +770,8 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
}
/* copy layers and flags from bases to objects */
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
ob = base->object;
/* collection patch... */
BKE_scene_object_base_flag_sync_from_base(base);
@@ -929,7 +925,7 @@ int BKE_scene_base_iter_next(
Scene *BKE_scene_find_from_collection(const Main *bmain, const Collection *collection)
{
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- for (ViewLayer *layer = scene->view_layers.first; layer; layer = layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, layer, &scene->view_layers) {
if (BKE_view_layer_has_collection(layer, collection)) {
return scene;
}
@@ -955,7 +951,7 @@ Object *BKE_scene_camera_switch_find(Scene *scene)
Object *camera = NULL;
Object *first_camera = NULL;
- for (TimeMarker *m = scene->markers.first; m; m = m->next) {
+ LISTBASE_FOREACH (TimeMarker *, m, &scene->markers) {
if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0) {
if ((m->frame <= cfra) && (m->frame > frame)) {
camera = m->camera;
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 37ea6c2cb4d..38bd0211d15 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -724,7 +724,7 @@ void BKE_screen_remove_unused_scrverts(bScreen *screen)
ARegion *BKE_area_find_region_type(const ScrArea *area, int region_type)
{
if (area) {
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == region_type) {
return region;
}
@@ -771,7 +771,7 @@ ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int
ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x, int y)
{
ARegion *region_found = NULL;
- for (ARegion *region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) {
if (BLI_rcti_isect_pt(&region->winrct, x, y)) {
region_found = region;
@@ -828,7 +828,7 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap,
int x,
int y)
{
- for (ScrArea *area = areamap->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) {
if (BLI_rcti_isect_pt(&area->totrct, x, y)) {
if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) {
return area;
@@ -915,8 +915,8 @@ bool BKE_screen_is_used(const bScreen *screen)
void BKE_screen_header_alignment_reset(bScreen *screen)
{
int alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP;
- 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 (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
if (ELEM(area->spacetype, SPACE_FILE, SPACE_USERPREF, SPACE_OUTLINER, SPACE_PROPERTIES)) {
region->alignment = RGN_ALIGN_TOP;
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index c471a6d254c..6acc50f30e9 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -3166,7 +3166,6 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for
/* XXX - new in 2.5x. should we use the animation system this way?
* The fcurve is needed because many frames need evaluating at once - campbell */
fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL);
-
if (!v->frameMap || v->length != seq->len) {
if (v->frameMap) {
MEM_freeN(v->frameMap);
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 996a9f34b61..0e558db57cb 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -1459,7 +1459,7 @@ static int evaluate_seq_frame_gen(Sequence **seq_arr, ListBase *seqbase, int cfr
memset(seq_arr, 0, sizeof(Sequence *) * (MAXSEQ + 1));
- for (Sequence *seq = seqbase->first; seq; seq = seq->next) {
+ LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if ((seq->startdisp <= cfra) && (seq->enddisp > cfra)) {
if ((seq->type & SEQ_TYPE_EFFECT) && !(seq->flag & SEQ_MUTE)) {
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 94c41777cea..3cdf3b40ce3 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -164,7 +164,7 @@ static void text_copy_data(Main *UNUSED(bmain),
text_dst->compiled = NULL;
/* Walk down, reconstructing. */
- for (TextLine *line_src = text_src->lines.first; line_src; line_src = line_src->next) {
+ LISTBASE_FOREACH (TextLine *, line_src, &text_src->lines) {
TextLine *line_dst = MEM_mallocN(sizeof(*line_dst), __func__);
line_dst->line = BLI_strdup(line_src->line);
@@ -1311,12 +1311,12 @@ void txt_sel_set(Text *text, int startl, int startc, int endl, int endc)
char *txt_to_buf_for_undo(Text *text, int *r_buf_len)
{
int buf_len = 0;
- for (const TextLine *l = text->lines.first; l; l = l->next) {
+ LISTBASE_FOREACH (const TextLine *, l, &text->lines) {
buf_len += l->len + 1;
}
char *buf = MEM_mallocN(buf_len, __func__);
char *buf_step = buf;
- for (const TextLine *l = text->lines.first; l; l = l->next) {
+ LISTBASE_FOREACH (const TextLine *, l, &text->lines) {
memcpy(buf_step, l->line, l->len);
buf_step += l->len;
*buf_step++ = '\n';
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index fd85e5ca212..fe10861f96e 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -697,7 +697,7 @@ static void texture_nodes_fetch_images_for_pool(Tex *texture,
bNodeTree *ntree,
struct ImagePool *pool)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_IMAGE && node->id != NULL) {
Image *image = (Image *)node->id;
BKE_image_pool_acquire_ibuf(image, &texture->iuser, pool);
diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c
index 5c1f6caad9d..46870a03e62 100644
--- a/source/blender/blenkernel/intern/tracking_solver.c
+++ b/source/blender/blenkernel/intern/tracking_solver.c
@@ -600,7 +600,7 @@ static void tracking_scale_reconstruction(ListBase *tracksbase,
sub_v3_v3(camera->mat[3], first_camera_delta);
}
- for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) {
+ LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
if (track->flag & TRACK_HAS_BUNDLE) {
mul_v3_v3(track->bundle_pos, scale);
sub_v3_v3(track->bundle_pos, first_camera_delta);
diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c
index 847522a0a66..e776e9bedb0 100644
--- a/source/blender/blenkernel/intern/undo_system.c
+++ b/source/blender/blenkernel/intern/undo_system.c
@@ -110,7 +110,7 @@ static ListBase g_undo_types = {NULL, NULL};
static const UndoType *BKE_undosys_type_from_context(bContext *C)
{
- for (const UndoType *ut = g_undo_types.first; ut; ut = ut->next) {
+ LISTBASE_FOREACH (const UndoType *, ut, &g_undo_types) {
/* No poll means we don't check context. */
if (ut->poll && ut->poll(C)) {
return ut;
@@ -143,7 +143,7 @@ static void undosys_id_ref_resolve(void *user_data, UndoRefID *id_ref)
* for now it's not too bad since it only runs when we access undo! */
Main *bmain = user_data;
ListBase *lb = which_libbase(bmain, GS(id_ref->name));
- for (ID *id = lb->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lb) {
if (STREQ(id_ref->name, id->name) && (id->lib == NULL)) {
id_ref->ptr = id;
break;
@@ -857,7 +857,7 @@ static void UNUSED_FUNCTION(BKE_undosys_foreach_ID_ref(UndoStack *ustack,
UndoTypeForEachIDRefFn foreach_ID_ref_fn,
void *user_data))
{
- for (UndoStep *us = ustack->steps.first; us; us = us->next) {
+ LISTBASE_FOREACH (UndoStep *, us, &ustack->steps) {
const UndoType *ut = us->type;
if (ut->step_foreach_ID_ref != NULL) {
ut->step_foreach_ID_ref(us, foreach_ID_ref_fn, user_data);
@@ -876,7 +876,7 @@ void BKE_undosys_print(UndoStack *ustack)
printf("Undo %d Steps (*: active, #=applied, M=memfile-active, S=skip)\n",
BLI_listbase_count(&ustack->steps));
int index = 0;
- for (UndoStep *us = ustack->steps.first; us; us = us->next) {
+ LISTBASE_FOREACH (UndoStep *, us, &ustack->steps) {
printf("[%c%c%c%c] %3d {%p} type='%s', name='%s'\n",
(us == ustack->step_active) ? '*' : ' ',
us->is_applied ? '#' : ' ',
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c
index 66a3c2cdced..c65d55785c1 100644
--- a/source/blender/blenkernel/intern/workspace.c
+++ b/source/blender/blenkernel/intern/workspace.c
@@ -396,7 +396,7 @@ void BKE_workspace_id_tag_all_visible(Main *bmain, int tag)
{
BKE_main_id_tag_listbase(&bmain->workspaces, tag, false);
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
workspace->id.tag |= tag;
}
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index c87dbee0f0e..85fbe7ece0f 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -406,7 +406,7 @@ static void bchunk_list_decref(BArrayMemory *bs_mem, BChunkList *chunk_list)
static size_t bchunk_list_data_check(const BChunkList *chunk_list, const uchar *data)
{
size_t offset = 0;
- for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) {
if (memcmp(&data[offset], cref->link->data, cref->link->data_len) != 0) {
return false;
}
@@ -1511,7 +1511,7 @@ void BLI_array_store_clear(BArrayStore *bs)
size_t BLI_array_store_calc_size_expanded_get(const BArrayStore *bs)
{
size_t size_accum = 0;
- for (const BArrayState *state = bs->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (const BArrayState *, state, &bs->states) {
size_accum += state->chunk_list->total_size;
}
return size_accum;
@@ -1632,14 +1632,14 @@ void BLI_array_store_state_data_get(BArrayState *state, void *data)
{
#ifdef USE_PARANOID_CHECKS
size_t data_test_len = 0;
- for (BChunkRef *cref = state->chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &state->chunk_list->chunk_refs) {
data_test_len += cref->link->data_len;
}
BLI_assert(data_test_len == state->chunk_list->total_size);
#endif
uchar *data_step = (uchar *)data;
- for (BChunkRef *cref = state->chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &state->chunk_list->chunk_refs) {
BLI_assert(cref->link->users > 0);
memcpy(data_step, cref->link->data, cref->link->data_len);
data_step += cref->link->data_len;
@@ -1666,7 +1666,7 @@ void *BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_le
static size_t bchunk_list_size(const BChunkList *chunk_list)
{
size_t total_size = 0;
- for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) {
total_size += cref->link->data_len;
}
return total_size;
@@ -1679,7 +1679,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
/* Check Length
* ------------ */
- for (BArrayState *state = bs->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (BArrayState *, state, &bs->states) {
BChunkList *chunk_list = state->chunk_list;
if (!(bchunk_list_size(chunk_list) == chunk_list->total_size)) {
return false;
@@ -1692,7 +1692,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
#ifdef USE_MERGE_CHUNKS
/* ensure we merge all chunks that could be merged */
if (chunk_list->total_size > bs->info.chunk_byte_size_min) {
- for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) {
if (cref->link->data_len < bs->info.chunk_byte_size_min) {
return false;
}
@@ -1734,7 +1734,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
GHash *chunk_map = BLI_ghash_ptr_new(__func__);
int totrefs = 0;
- for (BArrayState *state = bs->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (BArrayState *, state, &bs->states) {
GHASH_PTR_ADD_USER(chunk_list_map, state->chunk_list);
}
GHASH_ITER (gh_iter, chunk_list_map) {
@@ -1753,7 +1753,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
/* count chunk's */
GHASH_ITER (gh_iter, chunk_list_map) {
const struct BChunkList *chunk_list = BLI_ghashIterator_getKey(&gh_iter);
- for (const BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (const BChunkRef *, cref, &chunk_list->chunk_refs) {
GHASH_PTR_ADD_USER(chunk_map, cref->link);
totrefs += 1;
}
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 0a574ea34ca..31e8581590a 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -93,11 +93,9 @@ static TaskScheduler *task_scheduler = NULL;
* for (go over all jobs)
* if (job is ready) {
* if (job was not removed) {
- * BLI_threadpool_remove(&lb, job);
- * }
+ * BLI_threadpool_remove(&lb, job); * }
* }
- * else cont = 1;
- * }
+ * else cont = 1; * }
* // conditions to exit loop
* if (if escape loop event) {
* if (BLI_available_threadslots(&lb) == maxthreads) {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 259602ecec6..84af4d1a3d4 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2670,7 +2670,7 @@ static void IDP_LibLinkProperty(IDProperty *prop, FileData *fd)
}
case IDP_GROUP: /* PointerProperty */
{
- for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
+ LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
IDP_LibLinkProperty(loop, fd);
}
break;
@@ -3030,7 +3030,7 @@ static PackedFile *direct_link_packedfile(FileData *fd, PackedFile *oldpf)
// XXX deprecated - old animation system
static void lib_link_ipo(FileData *fd, Main *UNUSED(bmain), Ipo *ipo)
{
- for (IpoCurve *icu = ipo->curve.first; icu; icu = icu->next) {
+ LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
if (icu->driver) {
icu->driver->ob = newlibadr(fd, ipo->id.lib, icu->driver->ob);
}
@@ -3251,7 +3251,7 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
static void lib_link_action(FileData *fd, Main *UNUSED(bmain), bAction *act)
{
// XXX deprecated - old animation system <<<
- for (bActionChannel *chan = act->chanbase.first; chan; chan = chan->next) {
+ LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
chan->ipo = newlibadr(fd, act->id.lib, chan->ipo);
lib_link_constraint_channels(fd, &act->id, &chan->constraintChannels);
}
@@ -3259,7 +3259,7 @@ static void lib_link_action(FileData *fd, Main *UNUSED(bmain), bAction *act)
lib_link_fcurves(fd, &act->id, &act->curves);
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if (marker->camera) {
marker->camera = newlibadr(fd, act->id.lib, marker->camera);
}
@@ -3515,8 +3515,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
link_list(fd, &workspace->owner_ids);
link_list(fd, &workspace->tools);
- for (WorkSpaceDataRelation *relation = workspace->hook_layout_relations.first; relation;
- relation = relation->next) {
+ LISTBASE_FOREACH (WorkSpaceDataRelation *, relation, &workspace->hook_layout_relations) {
/* data from window - need to access through global oldnew-map */
relation->parent = newglobadr(fd, relation->parent);
@@ -3527,7 +3526,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
/* Same issue/fix as in direct_link_workspace_link_scene_data: Can't read workspace data
* when reading windows, so have to update windows after/when reading workspaces. */
for (wmWindowManager *wm = main->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WorkSpaceLayout *act_layout = newdataadr(
fd, BKE_workspace_active_layout_get(win->workspace_hook));
if (act_layout) {
@@ -3536,7 +3535,7 @@ static void direct_link_workspace(FileData *fd, WorkSpace *workspace, const Main
}
}
- for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
tref->runtime = NULL;
tref->properties = newdataadr(fd, tref->properties);
IDP_DirectLinkGroup_OrFree(&tref->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
@@ -3564,25 +3563,25 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
ntree->gpd = newlibadr(fd, lib, ntree->gpd);
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* Link ID Properties -- and copy this comment EXACTLY for easy finding
* of library blocks that implement this.*/
IDP_LibLinkProperty(node->prop, fd);
node->id = newlibadr(fd, lib, node->id);
- for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
- for (bNodeSocket *sock = node->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
}
- for (bNodeSocket *sock = ntree->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->inputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
- for (bNodeSocket *sock = ntree->outputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &ntree->outputs) {
IDP_LibLinkProperty(sock->prop, fd);
}
@@ -3595,7 +3594,7 @@ static void lib_link_ntree(FileData *fd, Library *lib, bNodeTree *ntree)
/* For nodes with static socket layout, add/remove sockets as needed
* to match the static layout. */
if (fd->memfile == NULL) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
node_verify_socket_templates(ntree, node);
}
}
@@ -3929,7 +3928,7 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
}
}
- for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
lib_link_constraints(fd, (ID *)ob, &pchan->constraints);
pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
@@ -3958,14 +3957,14 @@ static void lib_link_bones(FileData *fd, Bone *bone)
{
IDP_LibLinkProperty(bone->prop, fd);
- for (Bone *curbone = bone->childbase.first; curbone; curbone = curbone->next) {
+ LISTBASE_FOREACH (Bone *, curbone, &bone->childbase) {
lib_link_bones(fd, curbone);
}
}
static void lib_link_armature(FileData *fd, Main *UNUSED(bmain), bArmature *arm)
{
- for (Bone *curbone = arm->bonebase.first; curbone; curbone = curbone->next) {
+ LISTBASE_FOREACH (Bone *, curbone, &arm->bonebase) {
lib_link_bones(fd, curbone);
}
}
@@ -4026,7 +4025,7 @@ static void lib_link_camera(FileData *fd, Main *UNUSED(bmain), Camera *ca)
ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); /* deprecated, for versioning */
ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object);
- for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) {
bgpic->ima = newlibadr(fd, ca->id.lib, bgpic->ima);
bgpic->clip = newlibadr(fd, ca->id.lib, bgpic->clip);
}
@@ -4039,7 +4038,7 @@ static void direct_link_camera(FileData *fd, Camera *ca)
link_list(fd, &ca->bg_images);
- for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) {
bgpic->iuser.ok = 1;
bgpic->iuser.scene = NULL;
}
@@ -4614,7 +4613,7 @@ static void lib_link_particlesettings(FileData *fd, Main *UNUSED(bmain), Particl
}
if (part->instance_weights.first && part->instance_collection) {
- for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
dw->ob = newlibadr(fd, part->id.lib, dw->ob);
}
}
@@ -5259,7 +5258,7 @@ static void lib_link_object(FileData *fd, Main *bmain, Object *ob)
lib_link_nlastrips(fd, &ob->id, &ob->nlastrips);
// >>> XXX deprecated - old animation system
- for (PartEff *paf = ob->effect.first; paf; paf = paf->next) {
+ LISTBASE_FOREACH (PartEff *, paf, &ob->effect) {
if (paf->type == EFF_PARTICLE) {
paf->group = newlibadr(fd, ob->id.lib, paf->group);
}
@@ -6204,7 +6203,7 @@ static void direct_link_view_settings(FileData *fd, ColorManagedViewSettings *vi
static void direct_link_layer_collections(FileData *fd, ListBase *lb, bool master)
{
link_list(fd, lb);
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
#ifdef USE_COLLECTION_COMPAT_28
lc->scene_collection = newdataadr(fd, lc->scene_collection);
#endif
@@ -6257,12 +6256,11 @@ static void lib_link_layer_collection(FileData *fd,
static void lib_link_view_layer(FileData *fd, Library *lib, ViewLayer *view_layer)
{
- for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc;
- fmc = fmc->next) {
+ LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
fmc->script = newlibadr(fd, lib, fmc->script);
}
- for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) {
+ LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
fls->linestyle = newlibadr(fd, lib, fls->linestyle);
fls->group = newlibadr(fd, lib, fls->group);
}
@@ -6305,19 +6303,19 @@ static void direct_link_scene_collection(FileData *fd, SceneCollection *sc)
link_list(fd, &sc->objects);
link_list(fd, &sc->scene_collections);
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
+ LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
direct_link_scene_collection(fd, nsc);
}
}
static void lib_link_scene_collection(FileData *fd, Library *lib, SceneCollection *sc)
{
- for (LinkData *link = sc->objects.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
link->data = newlibadr(fd, lib, link->data);
BLI_assert(link->data);
}
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
+ LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
lib_link_scene_collection(fd, lib, nsc);
}
}
@@ -6625,7 +6623,7 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
}
SEQ_END;
- for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
if (marker->camera) {
marker->camera = newlibadr(fd, sce->id.lib, marker->camera);
}
@@ -6649,12 +6647,12 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
composite_patch(sce->nodetree, sce);
}
- for (SceneRenderLayer *srl = sce->r.layers.first; srl; srl = srl->next) {
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &sce->r.layers) {
srl->mat_override = newlibadr(fd, sce->id.lib, srl->mat_override);
- for (FreestyleModuleConfig *fmc = srl->freestyleConfig.modules.first; fmc; fmc = fmc->next) {
+ LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) {
fmc->script = newlibadr(fd, sce->id.lib, fmc->script);
}
- for (FreestyleLineSet *fls = srl->freestyleConfig.linesets.first; fls; fls = fls->next) {
+ LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) {
fls->linestyle = newlibadr(fd, sce->id.lib, fls->linestyle);
fls->group = newlibadr(fd, sce->id.lib, fls->group);
}
@@ -6668,7 +6666,7 @@ static void lib_link_scene(FileData *fd, Main *UNUSED(bmain), Scene *sce)
}
#endif
- for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
lib_link_view_layer(fd, sce->id.lib, view_layer);
}
@@ -7199,7 +7197,7 @@ static void direct_link_panel_list(FileData *fd, ListBase *lb)
{
link_list(fd, lb);
- for (Panel *pa = lb->first; pa; pa = pa->next) {
+ LISTBASE_FOREACH (Panel *, pa, lb) {
pa->runtime_flag = 0;
pa->activedata = NULL;
pa->type = NULL;
@@ -7524,7 +7522,7 @@ static void lib_link_area(FileData *fd, ID *parent_id, ScrArea *area)
memset(&area->runtime, 0x0, sizeof(area->runtime));
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
switch (sl->spacetype) {
case SPACE_VIEW3D: {
View3D *v3d = (View3D *)sl;
@@ -7701,12 +7699,12 @@ static bool direct_link_area_map(FileData *fd, ScrAreaMap *area_map)
link_list(fd, &area_map->vertbase);
link_list(fd, &area_map->edgebase);
link_list(fd, &area_map->areabase);
- for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
direct_link_area(fd, area);
}
/* edges */
- for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
+ LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
se->v1 = newdataadr(fd, se->v1);
se->v2 = newdataadr(fd, se->v2);
BKE_screen_sort_scrvert(&se->v1, &se->v2);
@@ -7823,7 +7821,7 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowManager *wm)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->workspace_hook) { /* NULL for old files */
lib_link_workspace_instance_hook(fd, win->workspace_hook, &wm->id);
}
@@ -7831,7 +7829,7 @@ static void lib_link_windowmanager(FileData *fd, Main *UNUSED(bmain), wmWindowMa
/* deprecated, but needed for versioning (will be NULL'ed then) */
win->screen = newlibadr(fd, NULL, win->screen);
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
lib_link_area(fd, &wm->id, area);
}
@@ -7856,7 +7854,7 @@ static void lib_link_screen(FileData *fd, Main *UNUSED(bmain), bScreen *screen)
screen->tool_tip = NULL;
screen->scrubbing = false;
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
lib_link_area(fd, &screen->id, area);
}
}
@@ -8010,8 +8008,8 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View
{
bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- 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;
@@ -8039,7 +8037,7 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View
/* Regionbase storage is different depending if the space is active. */
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->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
if (rv3d->localvd) {
@@ -8063,8 +8061,8 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map,
/* avoid conflicts with 2.8x branch */
{
- 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;
ARegion *region;
@@ -8303,12 +8301,12 @@ void blo_lib_link_restore(Main *oldmain,
workspace = workspace->id.next) {
ListBase *layouts = BKE_workspace_layouts_get(workspace);
- for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) {
lib_link_workspace_layout_restore(id_map, newmain, layout);
}
}
- for (wmWindow *win = curwm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &curwm->windows) {
WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
ID *workspace_id = (ID *)workspace;
Scene *oldscene = win->scene;
@@ -8686,7 +8684,7 @@ static void lib_link_movieclip(FileData *fd, Main *UNUSED(bmain), MovieClip *cli
lib_link_movieTracks(fd, clip, &tracking->tracks);
lib_link_moviePlaneTracks(fd, clip, &tracking->plane_tracks);
- for (MovieTrackingObject *object = tracking->objects.first; object; object = object->next) {
+ LISTBASE_FOREACH (MovieTrackingObject *, object, &tracking->objects) {
lib_link_movieTracks(fd, clip, &object->tracks);
lib_link_moviePlaneTracks(fd, clip, &object->plane_tracks);
}
@@ -8763,7 +8761,7 @@ static void lib_link_mask_parent(FileData *fd, Mask *mask, MaskParent *parent)
static void lib_link_mask(FileData *fd, Main *UNUSED(bmain), Mask *mask)
{
- for (MaskLayer *masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+ LISTBASE_FOREACH (MaskLayer *, masklay, &mask->masklayers) {
MaskSpline *spline;
spline = masklay->splines.first;
@@ -10119,14 +10117,14 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead)
}
}
- for (wmKeyConfigPref *kpt = user->user_keyconfig_prefs.first; kpt; kpt = kpt->next) {
+ LISTBASE_FOREACH (wmKeyConfigPref *, kpt, &user->user_keyconfig_prefs) {
kpt->prop = newdataadr(fd, kpt->prop);
IDP_DirectLinkGroup_OrFree(&kpt->prop, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
- for (bUserMenu *um = user->user_menus.first; um; um = um->next) {
+ LISTBASE_FOREACH (bUserMenu *, um, &user->user_menus) {
link_list(fd, &um->items);
- for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, &um->items) {
if (umi->type == USER_MENU_TYPE_OPERATOR) {
bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
umi_op->prop = newdataadr(fd, umi_op->prop);
@@ -10288,7 +10286,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
/* Yep, second splitting... but this is a very cheap operation, so no big deal. */
blo_split_main(&mainlist, bfd->main);
- for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) {
+ LISTBASE_FOREACH (Main *, mainvar, &mainlist) {
BLI_assert(mainvar->versionfile != 0);
do_versions_after_linking(mainvar, fd->reports);
}
@@ -10706,7 +10704,7 @@ static void expand_idprops(FileData *fd, Main *mainvar, IDProperty *prop)
break;
}
case IDP_GROUP:
- for (IDProperty *loop = prop->data.group.first; loop; loop = loop->next) {
+ LISTBASE_FOREACH (IDProperty *, loop, &prop->data.group) {
expand_idprops(fd, mainvar, loop);
}
break;
@@ -10766,7 +10764,7 @@ static void expand_action(FileData *fd, Main *mainvar, bAction *act)
/* F-Curves in Action */
expand_fcurves(fd, mainvar, &act->curves);
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if (marker->camera) {
expand_doit(fd, mainvar, marker->camera);
}
@@ -10834,18 +10832,18 @@ static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSetting
}
}
- for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
expand_doit(fd, mainvar, dw->ob);
}
}
static void expand_collection(FileData *fd, Main *mainvar, Collection *collection)
{
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
expand_doit(fd, mainvar, cob->ob);
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
expand_doit(fd, mainvar, child->collection);
}
@@ -11030,14 +11028,14 @@ static void expand_bones(FileData *fd, Main *mainvar, Bone *bone)
{
expand_idprops(fd, mainvar, bone->prop);
- for (Bone *curBone = bone->childbase.first; curBone; curBone = curBone->next) {
+ LISTBASE_FOREACH (Bone *, curBone, &bone->childbase) {
expand_bones(fd, mainvar, curBone);
}
}
static void expand_armature(FileData *fd, Main *mainvar, bArmature *arm)
{
- for (Bone *curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
+ LISTBASE_FOREACH (Bone *, curBone, &arm->bonebase) {
expand_bones(fd, mainvar, curBone);
}
}
@@ -11175,11 +11173,11 @@ static void expand_object(FileData *fd, Main *mainvar, Object *ob)
#ifdef USE_COLLECTION_COMPAT_28
static void expand_scene_collection(FileData *fd, Main *mainvar, SceneCollection *sc)
{
- for (LinkData *link = sc->objects.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
expand_doit(fd, mainvar, link->data);
}
- for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
+ LISTBASE_FOREACH (SceneCollection *, nsc, &sc->scene_collections) {
expand_scene_collection(fd, mainvar, nsc);
}
}
@@ -11191,7 +11189,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
FreestyleModuleConfig *module;
FreestyleLineSet *lineset;
- for (Base *base_legacy = sce->base.first; base_legacy; base_legacy = base_legacy->next) {
+ LISTBASE_FOREACH (Base *, base_legacy, &sce->base) {
expand_doit(fd, mainvar, base_legacy->object);
}
expand_doit(fd, mainvar, sce->camera);
@@ -11218,7 +11216,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
}
}
- for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
expand_idprops(fd, mainvar, view_layer->id_properties);
for (module = view_layer->freestyle_config.modules.first; module; module = module->next) {
@@ -11274,7 +11272,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
expand_doit(fd, mainvar, sce->rigidbody_world->constraints);
}
- for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
if (marker->camera) {
expand_doit(fd, mainvar, marker->camera);
}
@@ -11297,7 +11295,7 @@ static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
{
expand_doit(fd, mainvar, ca->ipo); // XXX deprecated - old animation system
- for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &ca->bg_images) {
if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) {
expand_doit(fd, mainvar, bgpic->ima);
}
@@ -11403,7 +11401,7 @@ static void expand_workspace(FileData *fd, Main *mainvar, WorkSpace *workspace)
{
ListBase *layouts = BKE_workspace_layouts_get(workspace);
- for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) {
expand_doit(fd, mainvar, BKE_workspace_layout_screen_get(layout));
}
}
@@ -12145,7 +12143,7 @@ static int has_linked_ids_to_read(Main *mainvar)
int a = set_listbasepointers(mainvar, lbarray);
while (a--) {
- for (ID *id = lbarray[a]->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lbarray[a]) {
if ((id->tag & LIB_TAG_ID_LINK_PLACEHOLDER) && !(id->flag & LIB_INDIRECT_WEAK_LINK)) {
return true;
}
diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c
index 69c4ba2b1f2..d8780409e93 100644
--- a/source/blender/blenloader/intern/undofile.c
+++ b/source/blender/blenloader/intern/undofile.c
@@ -95,7 +95,7 @@ void BLO_memfile_merge(MemFile *first, MemFile *second)
/* Clear is_identical_future before adding next memfile. */
void BLO_memfile_clear_future(MemFile *memfile)
{
- for (MemFileChunk *chunk = memfile->chunks.first; chunk; chunk = chunk->next) {
+ LISTBASE_FOREACH (MemFileChunk *, chunk, &memfile->chunks) {
chunk->is_identical_future = false;
}
}
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index f1f7b4cf353..98d2acbd938 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -258,7 +258,7 @@ static void do_version_action_editor_properties_region(ListBase *regionbase)
static void do_version_bones_super_bbone(ListBase *lb)
{
- for (Bone *bone = lb->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, lb) {
bone->scale_in_x = bone->scale_in_y = 1.0f;
bone->scale_out_x = bone->scale_out_y = 1.0f;
@@ -343,7 +343,7 @@ static void do_versions_compositor_render_passes_storage(bNode *node)
static void do_versions_compositor_render_passes(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_R_LAYERS) {
/* First we make sure existing sockets have proper names.
* This is important because otherwise verification will
@@ -392,7 +392,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),
/* Driver -> Driver Vars (for bbone_in/out) */
if (fcu->driver) {
- for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
if (dtar->rna_path) {
dtar->rna_path = replace_bbone_easing_rnapath(dtar->rna_path);
@@ -404,7 +404,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),
/* FModifiers -> Stepped (for frame_start/end) */
if (fcu->modifiers.first) {
- for (FModifier *fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
+ LISTBASE_FOREACH (FModifier *, fcm, &fcu->modifiers) {
if (fcm->type == FMODIFIER_TYPE_STEPPED) {
FMod_Stepped *data = fcm->data;
@@ -1153,7 +1153,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
* otherwise they could collide with any new persistent flag we may add in the future. */
a = set_listbasepointers(bmain, lbarray);
while (a--) {
- for (ID *id = lbarray[a]->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lbarray[a]) {
id->flag &= LIB_FAKEUSER;
}
}
@@ -1177,15 +1177,15 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
/* Bug: Was possible to add preview region to sequencer view by using AZones. */
if (sl->spacetype == SPACE_SEQ) {
SpaceSeq *sseq = (SpaceSeq *)sl;
if (sseq->view == SEQ_VIEW_SEQUENCE) {
- for (ARegion *region = regionbase->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, regionbase) {
/* remove preview region for sequencer-only view! */
if (region->regiontype == RGN_TYPE_PREVIEW) {
region->flag |= RGN_FLAG_HIDDEN;
@@ -1197,7 +1197,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
/* Remove old deprecated region from filebrowsers */
else if (sl->spacetype == SPACE_FILE) {
- for (ARegion *region = regionbase->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, regionbase) {
if (region->regiontype == RGN_TYPE_CHANNELS) {
/* Free old deprecated 'channel' region... */
BKE_area_region_free(NULL, region);
@@ -1245,9 +1245,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Adding "Properties" region to DopeSheet */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
/* handle pushed-back space data first */
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
do_version_action_editor_properties_region(&saction->regionbase);
@@ -1271,7 +1271,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "bPoseChannel", "float", "scaleIn")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->pose) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
/* see do_version_bones_super_bbone()... */
pchan->scale_in_x = pchan->scale_in_y = 1.0f;
pchan->scale_out_x = pchan->scale_out_y = 1.0f;
@@ -1561,8 +1561,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 278, 5)) {
/* Mask primitive adding code was not initializing correctly id_type of its points' parent. */
for (Mask *mask = bmain->masks.first; mask; mask = mask->id.next) {
- for (MaskLayer *mlayer = mask->masklayers.first; mlayer; mlayer = mlayer->next) {
- for (MaskSpline *mspline = mlayer->splines.first; mspline; mspline = mspline->next) {
+ LISTBASE_FOREACH (MaskLayer *, mlayer, &mask->masklayers) {
+ LISTBASE_FOREACH (MaskSpline *, mspline, &mlayer->splines) {
int i = 0;
for (MaskSplinePoint *mspoint = mspline->points; i < mspline->tot_point;
mspoint++, i++) {
@@ -1579,7 +1579,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
ntreeSetTypes(NULL, ntree);
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_GLARE) {
NodeGlare *ndg = node->storage;
switch (ndg->type) {
@@ -1601,7 +1601,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "mat[4][4]")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_SurfaceDeform) {
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
unit_m4(smd->mat);
@@ -1652,7 +1652,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 279, 4)) {
/* Fix for invalid state of screen due to bug in older versions. */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->full && screen->state == SCREENNORMAL) {
area->full = NULL;
}
@@ -1683,7 +1683,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
* Must set previous defaults. */
if (!DNA_struct_elem_find(fd->filesdna, "SimpleDeformModifierData", "char", "deform_axis")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_SimpleDeform) {
SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md;
smd->deform_axis = 2;
@@ -1712,7 +1712,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(
fd->filesdna, "ParticleInstanceModifierData", "float", "particle_amount")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_ParticleInstance) {
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
pimd->space = eParticleInstanceSpace_World;
@@ -1731,7 +1731,7 @@ void do_versions_after_linking_270(Main *bmain)
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_COMPOSIT) {
ntreeSetTypes(NULL, ntree);
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == CMP_NODE_HUE_SAT) {
do_version_hue_sat_node(ntree, node);
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 3821b2ad48a..ff87756f436 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -116,7 +116,7 @@ static bScreen *screen_parent_find(const bScreen *screen)
/* Can avoid lookup if screen state isn't maximized/full
* (parent and child store the same state). */
if (ELEM(screen->state, SCREENMAXIMIZED, SCREENFULL)) {
- for (const ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) {
if (area->full && area->full != screen) {
BLI_assert(area->full->state == screen->state);
return area->full;
@@ -159,7 +159,7 @@ static void do_version_area_change_space_to_space_action(ScrArea *area, const Sc
ARegion *region_channels;
/* Properly free current regions */
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
BKE_area_region_free(area->type, region);
}
BLI_freelistN(&area->regionbase);
@@ -199,7 +199,7 @@ static void do_version_workspaces_after_lib_link(Main *bmain)
do_version_workspaces_create_from_screens(bmain);
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen_parent = screen_parent_find(win->screen);
bScreen *screen = screen_parent ? screen_parent : win->screen;
@@ -278,7 +278,7 @@ static void do_version_layer_collection_pre(ViewLayer *view_layer,
GSet *selectable_set)
{
/* Convert from deprecated DISABLED to new layer collection and collection flags */
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
if (lc->scene_collection) {
if (!(lc->flag & COLLECTION_DEPRECATED_DISABLED)) {
BLI_gset_insert(enabled_set, lc->scene_collection);
@@ -300,7 +300,7 @@ static void do_version_layer_collection_post(ViewLayer *view_layer,
GHash *collection_map)
{
/* Apply layer collection exclude flags. */
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
if (!(lc->collection->flag & COLLECTION_IS_MASTER)) {
SceneCollection *sc = BLI_ghash_lookup(collection_map, lc->collection);
const bool enabled = (sc && BLI_gset_haskey(enabled_set, sc));
@@ -334,7 +334,7 @@ static void do_version_scene_collection_convert(
nsc = nsc_next;
}
- for (LinkData *link = sc->objects.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &sc->objects) {
Object *ob = link->data;
if (ob) {
BKE_collection_object_add(bmain, collection, ob);
@@ -422,7 +422,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
Collection *collections[20] = {NULL};
for (int layer = 0; layer < 20; layer++) {
- for (Base *base = scene->base.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &scene->base) {
if (base->lay & (1 << layer)) {
/* Create collections when needed only. */
if (collections[layer] == NULL) {
@@ -461,7 +461,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
bool have_override = false;
const bool need_default_renderlayer = scene->r.layers.first == NULL;
- for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &scene->r.layers) {
ViewLayer *view_layer = BKE_view_layer_add(scene, srl->name, NULL, VIEWLAYER_ADD_NEW);
if (srl->layflag & SCE_LAY_DISABLE) {
@@ -493,7 +493,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
/* Disable excluded layer. */
have_override = true;
lc->flag |= LAYER_COLLECTION_EXCLUDE;
- for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) {
nlc->flag |= LAYER_COLLECTION_EXCLUDE;
}
}
@@ -516,7 +516,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
view_layer->basact = BKE_view_layer_base_find(view_layer, scene->basact->object);
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
base->flag |= BASE_SELECTED;
}
@@ -542,7 +542,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
}
/* convert selected bases */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if ((base->flag & BASE_SELECTABLE) && (base->object->flag & SELECT)) {
base->flag |= BASE_SELECTED;
}
@@ -553,7 +553,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
}
/* remove bases once and for all */
- for (Base *base = scene->base.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &scene->base) {
id_us_min(&base->object->id);
}
@@ -577,8 +577,8 @@ static void do_version_collection_propagate_lib_to_children(Collection *collecti
/** convert old annotations colors */
static void do_versions_fix_annotations(bGPdata *gpd)
{
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) {
+ LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) {
/* fix layers */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* unlock/unhide layer */
@@ -620,7 +620,7 @@ static void do_versions_remove_regions_by_type(ListBase *regionbase, int regiont
static ARegion *do_versions_find_region_or_null(ListBase *regionbase, int regiontype)
{
- for (ARegion *region = regionbase->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, regionbase) {
if (region->regiontype == regiontype) {
return region;
}
@@ -649,8 +649,8 @@ static void do_versions_area_ensure_tool_region(Main *bmain,
const short region_flag)
{
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;
@@ -670,7 +670,7 @@ static void do_versions_area_ensure_tool_region(Main *bmain,
static void do_version_bones_split_bbone_scale(ListBase *lb)
{
- for (Bone *bone = lb->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, lb) {
bone->scale_in_y = bone->scale_in_x;
bone->scale_out_y = bone->scale_out_x;
@@ -680,7 +680,7 @@ static void do_version_bones_split_bbone_scale(ListBase *lb)
static void do_version_bones_inherit_scale(ListBase *lb)
{
- for (Bone *bone = lb->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, lb) {
if (bone->flag & BONE_NO_SCALE) {
bone->inherit_scale_mode = BONE_INHERIT_SCALE_NONE_LEGACY;
bone->flag &= ~BONE_NO_SCALE;
@@ -750,7 +750,7 @@ static void do_version_bbone_scale_animdata_cb(ID *UNUSED(id),
static void do_version_constraints_maintain_volume_mode_uniform(ListBase *lb)
{
- for (bConstraint *con = lb->first; con; con = con->next) {
+ LISTBASE_FOREACH (bConstraint *, con, lb) {
if (con->type == CONSTRAINT_TYPE_SAMEVOL) {
bSameVolumeConstraint *data = (bSameVolumeConstraint *)con->data;
data->mode = SAMEVOL_UNIFORM;
@@ -760,7 +760,7 @@ static void do_version_constraints_maintain_volume_mode_uniform(ListBase *lb)
static void do_version_constraints_copy_scale_power(ListBase *lb)
{
- for (bConstraint *con = lb->first; con; con = con->next) {
+ LISTBASE_FOREACH (bConstraint *, con, lb) {
if (con->type == CONSTRAINT_TYPE_SIZELIKE) {
bSizeLikeConstraint *data = (bSizeLikeConstraint *)con->data;
data->power = 1.0f;
@@ -770,7 +770,7 @@ static void do_version_constraints_copy_scale_power(ListBase *lb)
static void do_version_constraints_copy_rotation_mix_mode(ListBase *lb)
{
- for (bConstraint *con = lb->first; con; con = con->next) {
+ LISTBASE_FOREACH (bConstraint *, con, lb) {
if (con->type == CONSTRAINT_TYPE_ROTLIKE) {
bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data;
data->mix_mode = (data->flag & ROTLIKE_OFFSET) ? ROTLIKE_MIX_OFFSET : ROTLIKE_MIX_REPLACE;
@@ -1244,8 +1244,8 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
* so same layer as BKE_view_layer_default_view would return */
ViewLayer *layer = screen->scene->view_layers.first;
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *space = area->spacedata.first; space; space = space->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
if (space->spacetype == SPACE_OUTLINER) {
SpaceOutliner *soutliner = (SpaceOutliner *)space;
@@ -1274,8 +1274,8 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
if (!MAIN_VERSION_ATLEAST(bmain, 280, 0)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *space = area->spacedata.first; space; space = space->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
if (space->spacetype == SPACE_IMAGE) {
SpaceImage *sima = (SpaceImage *)space;
if ((sima) && (sima->gpd)) {
@@ -1305,7 +1305,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
/* Cleanup any remaining SceneRenderLayer data for files that were created
* with Blender 2.8 before the SceneRenderLayer > RenderLayer refactor. */
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
- for (SceneRenderLayer *srl = scene->r.layers.first; srl; srl = srl->next) {
+ LISTBASE_FOREACH (SceneRenderLayer *, srl, &scene->r.layers) {
if (srl->prop) {
IDP_FreeProperty(srl->prop);
}
@@ -1320,7 +1320,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
* no longer be visible.
* Here we correct this by setting a default draw size for those files. */
for (Object *object = bmain->objects.first; object; object = object->id.next) {
- for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
+ LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
if (psys->part->draw_size == 0.0f) {
psys->part->draw_size = 0.1f;
}
@@ -1332,7 +1332,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
for (Object *object = bmain->objects.first; object; object = object->id.next) {
if (object->particlesystem.first) {
object->duplicator_visibility_flag = OB_DUPLI_FLAG_VIEWPORT;
- for (ParticleSystem *psys = object->particlesystem.first; psys; psys = psys->next) {
+ LISTBASE_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
if (psys->part->draw & PART_DRAW_EMITTER) {
object->duplicator_visibility_flag |= OB_DUPLI_FLAG_RENDER;
break;
@@ -1363,9 +1363,9 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
* screens using the active scene of the window they're displayed in.
* Next, update remaining screens using first scene in main listbase. */
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
do_version_area_change_space_to_space_action(area, win->scene);
@@ -1377,7 +1377,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
}
if (scene != NULL) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (ELEM(area->butspacetype, SPACE_TIME, SPACE_LOGIC)) {
/* Areas that were already handled won't be handled again */
do_version_area_change_space_to_space_action(area, scene);
@@ -1414,7 +1414,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
int new_count = BKE_keyblock_curve_element_count(&cu->nurb);
- for (KeyBlock *block = cu->key->block.first; block; block = block->next) {
+ LISTBASE_FOREACH (KeyBlock *, block, &cu->key->block) {
int old_count = block->totelem;
void *old_data = block->data;
@@ -1428,7 +1428,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
float *oldptr = old_data;
float(*newptr)[3] = block->data;
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->bezt) {
BezTriple *bezt = nu->bezt;
@@ -1481,7 +1481,7 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
if (ob->pose && arm && arm->id.lib == ob->id.lib) {
bool rebuild = false;
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
/* If the 2.7 flag is enabled, processing is needed. */
if (pchan->bone && (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES)) {
/* If the settings in the Bone are not set, copy. */
@@ -1784,7 +1784,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ &&
STREQ(node->idname, "ShaderNodeOutputMetallic")) {
BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname));
@@ -1913,8 +1913,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* init grease pencil grids and paper */
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_color[3]")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_paper_opacity = 0.5f;
@@ -1974,8 +1974,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.light = V3D_LIGHTING_STUDIO;
@@ -2027,7 +2027,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
/* Calculate window width/height from screen vertices */
int win_width = 0, win_height = 0;
- for (ScrVert *vert = screen->vertbase.first; vert; vert = vert->next) {
+ LISTBASE_FOREACH (ScrVert *, vert, &screen->vertbase) {
win_width = MAX2(win_width, vert->vec.x);
win_height = MAX2(win_height, vert->vec.y);
}
@@ -2067,8 +2067,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 12)) {
/* Remove tool property regions. */
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 (ELEM(sl->spacetype, SPACE_VIEW3D, SPACE_CLIP)) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
@@ -2097,8 +2097,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Initialize new view3D options. */
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.light = V3D_LIGHTING_STUDIO;
@@ -2322,8 +2322,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_OUTLINER) {
SpaceOutliner *soops = (SpaceOutliner *)sl;
soops->filter_id_type = ID_GR;
@@ -2404,8 +2404,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.flag |= V3D_SHADING_SPECULAR_HIGHLIGHT;
@@ -2417,8 +2417,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.xray_alpha = 0.5f;
@@ -2432,8 +2432,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* when loading the internal file is loaded before the matcaps */
if (default_matcap) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE);
@@ -2445,8 +2445,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "wireframe_threshold")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.wireframe_threshold = 0.5f;
@@ -2457,8 +2457,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "cavity_valley_factor")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.cavity_valley_factor = 1.0f;
@@ -2470,8 +2470,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "xray_alpha_bone")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.xray_alpha_bone = 0.5f;
@@ -2496,8 +2496,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_elem_find(fd->filesdna, "SpaceAction", "char", "mode_prev")) {
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_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
/* "Dopesheet" should be default here,
@@ -2512,8 +2512,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d->drawtype == OB_TEXTURE) {
@@ -2537,8 +2537,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(
fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) {
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_VIEW3D) {
enum {
V3D_SHOW_MODE_SHADE_OVERRIDE = (1 << 15),
@@ -2556,8 +2556,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "background_type")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
copy_v3_fl(v3d->shading.background_color, 0.05f);
@@ -2621,8 +2621,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "short", "type")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
if (v3d->drawtype == OB_RENDER) {
@@ -2644,8 +2644,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* initialize grease pencil view data */
if (!DNA_struct_elem_find(fd->filesdna, "SpaceView3D", "float", "vertex_opacity")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->vertex_opacity = 1.0f;
@@ -2676,8 +2676,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_paper_opacity")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_paper_opacity = 0.5f;
@@ -2688,8 +2688,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_grid_opacity")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_grid_opacity = 0.5f;
@@ -2713,7 +2713,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Versioning code for Subsurf modifier. */
if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
if (smd->flags & eSubsurfModifierFlag_SubsurfUv_DEPRECATED) {
@@ -2729,7 +2729,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "quality")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
smd->quality = min_ii(smd->renderLevels, 3);
@@ -2740,7 +2740,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Versioning code for Multires modifier. */
if (!DNA_struct_elem_find(fd->filesdna, "MultiresModifier", "short", "quality")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
if (md->type == eModifierType_Multires) {
MultiresModifierData *mmd = (MultiresModifierData *)md;
mmd->quality = 3;
@@ -2757,7 +2757,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "ClothSimSettings", "short", "bending_model")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
ClothModifierData *clmd = NULL;
if (md->type == eModifierType_Cloth) {
clmd = (ClothModifierData *)md;
@@ -2797,7 +2797,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
@@ -2826,8 +2826,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 24)) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.edit_flag |= V3D_OVERLAY_EDIT_FACES | V3D_OVERLAY_EDIT_SEAMS |
@@ -2842,7 +2842,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "ShrinkwrapModifierData", "char", "shrinkMode")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Shrinkwrap) {
ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md;
if (smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) {
@@ -2860,7 +2860,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
ob->pd->pdef_cfrict = 5.0f;
}
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
@@ -2872,8 +2872,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.flag |= V3D_SHADING_XRAY_WIREFRAME;
@@ -2910,8 +2910,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 29)) {
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_VIEW3D) {
enum { V3D_OCCLUDE_WIRE = (1 << 14) };
View3D *v3d = (View3D *)sl;
@@ -2933,8 +2933,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/
if (!MAIN_VERSION_ATLEAST(bmain, 283, 1)) {
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) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
ARegion *region_header = do_versions_find_region_or_null(regionbase, RGN_TYPE_HEADER);
@@ -2957,8 +2957,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_PROPERTIES) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
@@ -2985,8 +2985,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* grease pencil fade layer opacity */
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "gpencil_fade_layer")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_fade_layer = 0.5f;
@@ -3190,8 +3190,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 34)) {
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, slink, &area->spacedata) {
if (slink->spacetype == SPACE_USERPREF) {
ARegion *navigation_region = BKE_spacedata_find_region_type(
slink, area, RGN_TYPE_NAV_BAR);
@@ -3219,8 +3219,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 36)) {
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "curvature_ridge_factor")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.curvature_ridge_factor = 1.0f;
@@ -3251,8 +3251,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Move studio_light selection to lookdev_light. */
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "lookdev_light[256]")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char) * 256);
@@ -3305,8 +3305,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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) {
switch (sl->spacetype) {
case SPACE_IMAGE: {
SpaceImage *sima = (SpaceImage *)sl;
@@ -3422,8 +3422,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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) {
switch (sl->spacetype) {
case SPACE_VIEW3D: {
enum { V3D_BACKFACE_CULLING = (1 << 10) };
@@ -3465,8 +3465,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_USERPREF) {
ARegion *execute_region = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_EXECUTE);
@@ -3524,8 +3524,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Add wireframe color. */
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "char", "wire_color_type")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.wire_color_type = V3D_SHADING_SINGLE_COLOR;
@@ -3627,7 +3627,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "min_vertices")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Triangulate) {
TriangulateModifierData *smd = (TriangulateModifierData *)md;
smd->min_vertices = 4;
@@ -3638,7 +3638,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
if (ntree->type == NTREE_SHADER) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* Fix missing version patching from earlier changes. */
if (STREQ(node->idname, "ShaderNodeOutputLamp")) {
STRNCPY(node->idname, "ShaderNodeOutputLight");
@@ -3677,7 +3677,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 54)) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
bool is_first_subdiv = true;
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Subsurf) {
SubsurfModifierData *smd = (SubsurfModifierData *)md;
if (is_first_subdiv) {
@@ -3704,8 +3704,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 55)) {
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_TEXT) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
@@ -3727,8 +3727,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 56)) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->gizmo_show_armature = V3D_GIZMO_SHOW_ARMATURE_BBONE |
@@ -3745,8 +3745,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 280, 57)) {
/* Enable Show Interpolation in dopesheet by default. */
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_ACTION) {
SpaceAction *saction = (SpaceAction *)sl;
if ((saction->flag & SACTION_SHOW_EXTREMES) == 0) {
@@ -3784,8 +3784,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* enable the axis aligned ortho grid by default */
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->gridflag |= V3D_SHOW_ORTHO_GRID;
@@ -3798,8 +3798,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Keep un-versioned until we're finished adding space types. */
{
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) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
/* All spaces that use tools must be eventually added. */
@@ -3829,8 +3829,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(fd->filesdna, "bSplineIKConstraint", "short", "yScaleMode")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
if (ob->pose) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
- for (bConstraint *con = pchan->constraints.first; con; con = con->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
+ LISTBASE_FOREACH (bConstraint *, con, &pchan->constraints) {
if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
bSplineIKConstraint *data = (bSplineIKConstraint *)con->data;
if ((data->flag & CONSTRAINT_SPLINEIK_SCALE_LIMITED) == 0) {
@@ -3846,8 +3846,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(
fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.sculpt_mode_mask_opacity = 0.75f;
@@ -3910,8 +3910,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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 (ELEM(sl->spacetype, SPACE_CLIP, SPACE_GRAPH, SPACE_SEQ)) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
@@ -3936,8 +3936,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_OUTLINER) {
continue;
}
@@ -4047,7 +4047,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 281, 1)) {
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_DataTransfer) {
/* Now datatransfer's mix factor is multiplied with weights when any,
* instead of being ignored,
@@ -4063,8 +4063,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 281, 3)) {
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_TEXT) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
@@ -4118,8 +4118,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 281, 6)) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.flag |= V3D_SHADING_SCENE_LIGHTS_RENDER | V3D_SHADING_SCENE_WORLD_RENDER;
@@ -4140,8 +4140,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 281, 9)) {
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_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
@@ -4197,8 +4197,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Added studiolight intensity */
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_intensity")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.studiolight_intensity = 1.0f;
@@ -4235,15 +4235,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
- for (ScrArea *area_other = screen->areabase.first; area_other;
- area_other = area_other->next) {
- for (SpaceLink *sl_other = area_other->spacedata.first; sl_other;
- sl_other = sl_other->next) {
+ LISTBASE_FOREACH (ScrArea *, area_other, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, sl_other, &area_other->spacedata) {
if (sl != sl_other && sl_other->spacetype == SPACE_VIEW3D) {
View3D *v3d_other = (View3D *)sl_other;
@@ -4293,7 +4291,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
do_version_curvemapping_walker(bmain, do_version_curvemapping_flag_extend_extrapolate);
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
area->flag &= ~AREA_FLAG_UNUSED_6;
}
}
@@ -4311,7 +4309,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Add custom curve profile to bevel modifier */
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifier", "CurveProfile", "custom_profile")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
if (md->type == eModifierType_Bevel) {
BevelModifierData *bmd = (BevelModifierData *)md;
if (!bmd->custom_profile) {
@@ -4339,7 +4337,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Cloth pressure */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
@@ -4364,8 +4362,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.render_pass = SCE_PASS_COMBINED;
@@ -4377,8 +4375,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Make markers region visible by default. */
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) {
switch (sl->spacetype) {
case SPACE_SEQ: {
SpaceSeq *sseq = (SpaceSeq *)sl;
@@ -4413,7 +4411,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Cloth internal springs */
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData *)md;
@@ -4439,8 +4437,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* UDIM Image Editor change. */
if (!DNA_struct_elem_find(fd->filesdna, "SpaceImage", "int", "tile_grid_shape[2]")) {
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_IMAGE) {
SpaceImage *sima = (SpaceImage *)sl;
sima->tile_grid_shape[0] = 1;
@@ -4502,7 +4500,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Add 2D transform to UV Warp modifier. */
if (!DNA_struct_elem_find(fd->filesdna, "UVWarpModifierData", "float", "scale[2]")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_UVWarp) {
UVWarpModifierData *umd = (UVWarpModifierData *)md;
copy_v2_fl(umd->scale, 1.0f);
@@ -4514,8 +4512,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Add Lookdev blur property. */
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_blur")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->shading.studiolight_blur = 0.5f;
@@ -4788,8 +4786,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!DNA_struct_elem_find(
fd->filesdna, "View3DOverlay", "float", "sculpt_mode_face_sets_opacity")) {
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_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.sculpt_mode_face_sets_opacity = 1.0f;
@@ -4819,7 +4817,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Corrective smooth modifier scale*/
if (!DNA_struct_elem_find(fd->filesdna, "CorrectiveSmoothModifierData", "float", "scale")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_CorrectiveSmooth) {
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
csmd->scale = 1.0f;
@@ -4842,7 +4840,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 283, 11)) {
if (!DNA_struct_elem_find(fd->filesdna, "OceanModifierData", "float", "fetch_jonswap")) {
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
- for (ModifierData *md = object->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
if (md->type == eModifierType_Ocean) {
OceanModifierData *omd = (OceanModifierData *)md;
omd->fetch_jonswap = 120.0f;
@@ -4870,7 +4868,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Surface deform modifier strength*/
if (!DNA_struct_elem_find(fd->filesdna, "SurfaceDeformModifierData", "float", "strength")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_SurfaceDeform) {
SurfaceDeformModifierData *sdmd = (SurfaceDeformModifierData *)md;
sdmd->strength = 1.0f;
@@ -4896,7 +4894,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
/* Remesh Modifier Voxel Mode. */
if (!DNA_struct_elem_find(fd->filesdna, "RemeshModifierData", "float", "voxel_size")) {
for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Remesh) {
RemeshModifierData *rmd = (RemeshModifierData *)md;
rmd->voxel_size = 0.1f;
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
index 14a940b9297..ff3d4574561 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -173,7 +173,7 @@ static void square_roughness_node_insert(bNodeTree *ntree)
bool need_update = false;
/* Update default values */
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node_has_roughness(node)) {
bNodeSocket *roughness_input = nodeFindSocket(node, SOCK_IN, "Roughness");
float *roughness_value = cycles_node_socket_float_value(roughness_input);
@@ -256,7 +256,7 @@ static void ambient_occlusion_node_relink(bNodeTree *ntree)
bool need_update = false;
/* Set default values. */
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_AMBIENT_OCCLUSION) {
node->custom1 = 1; /* samples */
node->custom2 &= ~SHD_AO_LOCAL;
@@ -338,7 +338,7 @@ static void light_emission_node_to_energy(Light *light, float *energy, float col
}
bNode *emission_node = NULL;
- for (bNodeLink *link = ntree->links.first; link; link = link->next) {
+ LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
if (link->tonode == output_node && link->fromnode->type == SH_NODE_EMISSION) {
emission_node = link->fromnode;
break;
@@ -410,7 +410,7 @@ static void update_math_node_single_operand_operators(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_MATH) {
if (ELEM(node->custom1,
NODE_MATH_SQRT,
@@ -459,7 +459,7 @@ static void update_vector_math_node_add_and_subtract_operators(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_VECTOR_MATH) {
bNodeSocket *sockOutValue = nodeFindSocket(node, SOCK_OUT, "Value");
if (socket_is_used(sockOutValue) &&
@@ -511,7 +511,7 @@ static void update_vector_math_node_dot_product_operator(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_VECTOR_MATH) {
bNodeSocket *sockOutVector = nodeFindSocket(node, SOCK_OUT, "Vector");
if (socket_is_used(sockOutVector) && node->custom1 == NODE_VECTOR_MATH_DOT_PRODUCT) {
@@ -550,7 +550,7 @@ static void update_vector_math_node_cross_product_operator(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_VECTOR_MATH) {
if (node->custom1 == NODE_VECTOR_MATH_CROSS_PRODUCT) {
bNodeSocket *sockOutVector = nodeFindSocket(node, SOCK_OUT, "Vector");
@@ -616,7 +616,7 @@ static void update_vector_math_node_normalize_operator(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_VECTOR_MATH) {
bNodeSocket *sockOutValue = nodeFindSocket(node, SOCK_OUT, "Value");
if (node->custom1 == NODE_VECTOR_MATH_NORMALIZE && socket_is_used(sockOutValue)) {
@@ -675,7 +675,7 @@ static void update_vector_math_node_normalize_operator(bNodeTree *ntree)
*/
static void update_vector_math_node_operators_enum_mapping(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_VECTOR_MATH) {
switch (node->custom1) {
case 2:
@@ -702,7 +702,7 @@ static void update_vector_math_node_average_operator(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_VECTOR_MATH) {
/* See update_vector_math_node_operators_enum_mapping. */
if (node->custom1 == -1) {
@@ -765,7 +765,7 @@ static void update_vector_math_node_average_operator(bNodeTree *ntree)
*/
static void update_noise_node_dimensions(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_NOISE && node->storage) {
NodeTexNoise *tex = (NodeTexNoise *)node->storage;
tex->dimensions = 3;
@@ -853,7 +853,7 @@ static void update_mapping_node_inputs_and_properties(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
/* If node->storage is NULL, then conversion has already taken place.
* This can happen if a file with the new mapping node [saved from (2, 81, 8) or newer]
* is opened in a blender version prior to (2, 81, 8) and saved from there again. */
@@ -949,7 +949,7 @@ static void update_mapping_node_inputs_and_properties(bNodeTree *ntree)
*/
static void update_musgrave_node_dimensions(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_MUSGRAVE && node->storage) {
NodeTexMusgrave *tex = (NodeTexMusgrave *)node->storage;
tex->dimensions = 3;
@@ -977,7 +977,7 @@ static void update_musgrave_node_color_output(bNodeTree *ntree)
*/
static void update_voronoi_node_dimensions(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_VORONOI && node->storage) {
NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage;
tex->dimensions = 3;
@@ -992,7 +992,7 @@ static void update_voronoi_node_dimensions(bNodeTree *ntree)
*/
static void update_voronoi_node_f3_and_f4(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_VORONOI && node->storage) {
NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage;
if (ELEM(tex->feature, 2, 3)) {
@@ -1010,7 +1010,7 @@ static void update_voronoi_node_f3_and_f4(bNodeTree *ntree)
*/
static void update_voronoi_node_fac_output(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_VORONOI) {
bNodeSocket *facOutput = BLI_findlink(&node->outputs, 1);
strcpy(facOutput->identifier, "Distance");
@@ -1040,7 +1040,7 @@ static void update_voronoi_node_crackle(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_VORONOI && node->storage) {
NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage;
bNodeSocket *sockDistance = nodeFindSocket(node, SOCK_OUT, "Distance");
@@ -1169,7 +1169,7 @@ static void update_voronoi_node_square_distance(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_VORONOI && node->storage) {
NodeTexVoronoi *tex = (NodeTexVoronoi *)node->storage;
bNodeSocket *sockDistance = nodeFindSocket(node, SOCK_OUT, "Distance");
@@ -1213,7 +1213,7 @@ static void update_noise_and_wave_distortion(bNodeTree *ntree)
{
bool need_update = false;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_NOISE || node->type == SH_NODE_TEX_WAVE) {
bNodeSocket *sockDistortion = nodeFindSocket(node, SOCK_IN, "Distortion");
@@ -1262,7 +1262,7 @@ static void update_noise_and_wave_distortion(bNodeTree *ntree)
*/
static void update_wave_node_directions_and_offset(bNodeTree *ntree)
{
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_WAVE) {
NodeTexWave *tex = (NodeTexWave *)node->storage;
tex->bands_direction = SHD_WAVE_BANDS_DIRECTION_DIAGONAL;
@@ -1351,13 +1351,13 @@ void do_versions_after_linking_cycles(Main *bmain)
if (!MAIN_VERSION_ATLEAST(bmain, 273, 5)) {
/* Euler order was ZYX in previous versions. */
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
mapping_node_order_flip(node);
}
}
if (!MAIN_VERSION_ATLEAST(bmain, 276, 6)) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
vector_curve_node_remap(node);
}
}
@@ -1368,7 +1368,7 @@ void do_versions_after_linking_cycles(Main *bmain)
}
if (!MAIN_VERSION_ATLEAST(bmain, 279, 3)) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
displacement_principled_nodes(node);
}
}
@@ -1384,7 +1384,7 @@ void do_versions_after_linking_cycles(Main *bmain)
}
if (!MAIN_VERSION_ATLEAST(bmain, 280, 66)) {
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
image_node_colorspace(node);
}
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index aa19b3feefb..035e6c88faa 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -71,7 +71,7 @@ static ID *rename_id_for_versioning(Main *bmain,
/* We can ignore libraries */
ListBase *lb = which_libbase(bmain, id_type);
ID *id = NULL;
- for (ID *idtest = lb->first; idtest; idtest = idtest->next) {
+ LISTBASE_FOREACH (ID *, idtest, lb) {
if (idtest->lib == NULL) {
if (STREQ(idtest->name + 2, name_src)) {
id = idtest;
@@ -101,8 +101,8 @@ static void blo_update_defaults_screen(bScreen *screen,
const char *workspace_name)
{
/* For all app templates. */
- 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) {
/* Some toolbars have been saved as initialized,
* we don't want them to have odd zoom-level or scrolling set, see: T47047 */
if (ELEM(region->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) {
@@ -111,7 +111,7 @@ static void blo_update_defaults_screen(bScreen *screen,
}
/* Set default folder. */
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_FILE) {
SpaceFile *sfile = (SpaceFile *)sl;
if (sfile->params) {
@@ -130,8 +130,8 @@ static void blo_update_defaults_screen(bScreen *screen,
return;
}
- 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) {
/* Remove all stored panels, we want to use defaults
* (order, open/closed) as defined by UI code here! */
BKE_area_region_panels_free(&region->panels);
@@ -157,7 +157,7 @@ static void blo_update_defaults_screen(bScreen *screen,
if (saction->mode == SACTCONT_TIMELINE) {
saction->ads.flag |= ADS_FLAG_SUMMARY_COLLAPSED;
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_CHANNELS) {
region->flag |= RGN_FLAG_HIDDEN;
}
@@ -210,11 +210,11 @@ static void blo_update_defaults_screen(bScreen *screen,
/* Show tool-header by default (for most cases at least, hide for others). */
const bool hide_image_tool_header = STREQ(workspace_name, "Rendering");
- 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) {
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->regiontype == RGN_TYPE_TOOL_HEADER) {
if ((sl->spacetype == SPACE_IMAGE) && hide_image_tool_header) {
region->flag |= RGN_FLAG_HIDDEN;
@@ -229,8 +229,8 @@ static void blo_update_defaults_screen(bScreen *screen,
/* 2D animation template. */
if (app_template && STREQ(app_template, "2D_Animation")) {
- 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 (area->spacetype == SPACE_ACTION) {
SpaceAction *saction = area->spacedata.first;
/* Enable Sliders. */
@@ -251,7 +251,7 @@ static void blo_update_defaults_screen(bScreen *screen,
void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_template)
{
ListBase *layouts = BKE_workspace_layouts_get(workspace);
- for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) {
if (layout->screen) {
blo_update_defaults_screen(layout->screen, app_template, workspace->id.name + 2);
}
@@ -270,11 +270,11 @@ void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_templat
/* For Sculpting template. */
if (STREQ(workspace->id.name + 2, "Sculpting")) {
- for (WorkSpaceLayout *layout = layouts->first; layout; layout = layout->next) {
+ LISTBASE_FOREACH (WorkSpaceLayout *, layout, layouts) {
bScreen *screen = layout->screen;
if (screen) {
- 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 (area->spacetype == SPACE_VIEW3D) {
View3D *v3d = area->spacedata.first;
v3d->shading.flag &= ~V3D_SHADING_CAVITY;
@@ -472,7 +472,7 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template)
ma->roughness = 0.4f;
if (ma->nodetree) {
- for (bNode *node = ma->nodetree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ma->nodetree->nodes) {
if (node->type == SH_NODE_BSDF_PRINCIPLED) {
bNodeSocket *roughness_socket = nodeFindSocket(node, SOCK_IN, "Roughness");
bNodeSocketValueFloat *roughness_data = roughness_socket->default_value;
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index b566cf446ad..28118d6e87a 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -534,7 +534,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->gpu_viewport_quality = 0.6f;
/* Reset theme, old themes will not be compatible with minor version updates from now on. */
- for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
+ LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) {
memcpy(btheme, &U_theme_default, sizeof(*btheme));
}
@@ -552,8 +552,8 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
if (!USER_VERSION_ATLEAST(280, 31)) {
/* Remove select/action mouse from user defined keymaps. */
- for (wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) {
- for (wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
+ LISTBASE_FOREACH (wmKeyMap *, keymap, &userdef->user_keymaps) {
+ LISTBASE_FOREACH (wmKeyMapDiffItem *, kmdi, &keymap->diff_items) {
if (kmdi->remove_item) {
do_version_select_mouse(userdef, kmdi->remove_item);
}
@@ -562,7 +562,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
}
}
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
do_version_select_mouse(userdef, kmi);
}
}
@@ -757,7 +757,7 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
userdef->pixelsize = 1.0f;
}
- for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
+ LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) {
do_versions_theme(userdef, btheme);
}
#undef USER_VERSION_ATLEAST
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 43a27318d75..aa8dc39f9c0 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -718,13 +718,11 @@ static void write_iddata(WriteData *wd, ID *id)
writestruct(wd, DATA, IDOverrideLibrary, 1, id->override_library);
writelist(wd, DATA, IDOverrideLibraryProperty, &id->override_library->properties);
- for (IDOverrideLibraryProperty *op = id->override_library->properties.first; op;
- op = op->next) {
+ LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
writedata(wd, DATA, strlen(op->rna_path) + 1, op->rna_path);
writelist(wd, DATA, IDOverrideLibraryPropertyOperation, &op->operations);
- for (IDOverrideLibraryPropertyOperation *opop = op->operations.first; opop;
- opop = opop->next) {
+ LISTBASE_FOREACH (IDOverrideLibraryPropertyOperation *, opop, &op->operations) {
if (opop->subitem_reference_name) {
writedata(
wd, DATA, strlen(opop->subitem_reference_name) + 1, opop->subitem_reference_name);
@@ -863,11 +861,11 @@ static void write_action(WriteData *wd, bAction *act, const void *id_address)
write_fcurves(wd, &act->curves);
- for (bActionGroup *grp = act->groups.first; grp; grp = grp->next) {
+ LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
writestruct(wd, DATA, bActionGroup, 1, grp);
}
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
writestruct(wd, DATA, TimeMarker, 1, marker);
}
}
@@ -1231,14 +1229,14 @@ static void write_userdef(WriteData *wd, const UserDef *userdef)
{
writestruct(wd, USER, UserDef, 1, userdef);
- for (const bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
+ LISTBASE_FOREACH (const bTheme *, btheme, &userdef->themes) {
writestruct(wd, DATA, bTheme, 1, btheme);
}
- for (const wmKeyMap *keymap = userdef->user_keymaps.first; keymap; keymap = keymap->next) {
+ LISTBASE_FOREACH (const wmKeyMap *, keymap, &userdef->user_keymaps) {
writestruct(wd, DATA, wmKeyMap, 1, keymap);
- for (const wmKeyMapDiffItem *kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
+ LISTBASE_FOREACH (const wmKeyMapDiffItem *, kmdi, &keymap->diff_items) {
writestruct(wd, DATA, wmKeyMapDiffItem, 1, kmdi);
if (kmdi->remove_item) {
write_keymapitem(wd, kmdi->remove_item);
@@ -1248,21 +1246,21 @@ static void write_userdef(WriteData *wd, const UserDef *userdef)
}
}
- for (const wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (const wmKeyMapItem *, kmi, &keymap->items) {
write_keymapitem(wd, kmi);
}
}
- for (const wmKeyConfigPref *kpt = userdef->user_keyconfig_prefs.first; kpt; kpt = kpt->next) {
+ LISTBASE_FOREACH (const wmKeyConfigPref *, kpt, &userdef->user_keyconfig_prefs) {
writestruct(wd, DATA, wmKeyConfigPref, 1, kpt);
if (kpt->prop) {
IDP_WriteProperty(kpt->prop, wd);
}
}
- for (const bUserMenu *um = userdef->user_menus.first; um; um = um->next) {
+ LISTBASE_FOREACH (const bUserMenu *, um, &userdef->user_menus) {
writestruct(wd, DATA, bUserMenu, 1, um);
- for (const bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (const bUserMenuItem *, umi, &um->items) {
if (umi->type == USER_MENU_TYPE_OPERATOR) {
const bUserMenuItem_Op *umi_op = (const bUserMenuItem_Op *)umi;
writestruct(wd, DATA, bUserMenuItem_Op, 1, umi_op);
@@ -1284,19 +1282,18 @@ static void write_userdef(WriteData *wd, const UserDef *userdef)
}
}
- for (const bAddon *bext = userdef->addons.first; bext; bext = bext->next) {
+ LISTBASE_FOREACH (const bAddon *, bext, &userdef->addons) {
writestruct(wd, DATA, bAddon, 1, bext);
if (bext->prop) {
IDP_WriteProperty(bext->prop, wd);
}
}
- for (const bPathCompare *path_cmp = userdef->autoexec_paths.first; path_cmp;
- path_cmp = path_cmp->next) {
+ LISTBASE_FOREACH (const bPathCompare *, path_cmp, &userdef->autoexec_paths) {
writestruct(wd, DATA, bPathCompare, 1, path_cmp);
}
- for (const uiStyle *style = userdef->uistyles.first; style; style = style->next) {
+ LISTBASE_FOREACH (const uiStyle *, style, &userdef->uistyles) {
writestruct(wd, DATA, uiStyle, 1, style);
}
}
@@ -1416,7 +1413,7 @@ static void write_particlesettings(WriteData *wd, ParticleSettings *part, const
write_curvemapping(wd, part->twistcurve);
}
- for (ParticleDupliWeight *dw = part->instance_weights.first; dw; dw = dw->next) {
+ LISTBASE_FOREACH (ParticleDupliWeight *, dw, &part->instance_weights) {
/* update indices, but only if dw->ob is set (can be NULL after loading e.g.) */
if (dw->ob != NULL) {
dw->index = 0;
@@ -1436,7 +1433,7 @@ static void write_particlesettings(WriteData *wd, ParticleSettings *part, const
if (part->boids && part->phystype == PART_PHYS_BOIDS) {
writestruct(wd, DATA, BoidSettings, 1, part->boids);
- for (BoidState *state = part->boids->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (BoidState *, state, &part->boids->states) {
write_boid_state(wd, state);
}
}
@@ -1621,14 +1618,14 @@ static void write_pose(WriteData *wd, bPose *pose)
static void write_defgroups(WriteData *wd, ListBase *defbase)
{
- for (bDeformGroup *defgroup = defbase->first; defgroup; defgroup = defgroup->next) {
+ LISTBASE_FOREACH (bDeformGroup *, defgroup, defbase) {
writestruct(wd, DATA, bDeformGroup, 1, defgroup);
}
}
static void write_fmaps(WriteData *wd, ListBase *fbase)
{
- for (bFaceMap *fmap = fbase->first; fmap; fmap = fmap->next) {
+ LISTBASE_FOREACH (bFaceMap *, fmap, fbase) {
writestruct(wd, DATA, bFaceMap, 1, fmap);
}
}
@@ -2001,7 +1998,7 @@ static void write_key(WriteData *wd, Key *key, const void *id_address)
}
/* direct data */
- for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
+ LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
writestruct(wd, DATA, KeyBlock, 1, kb);
if (kb->data) {
writedata(wd, DATA, kb->totelem * key->elemsize, kb->data);
@@ -2021,7 +2018,7 @@ static void write_camera(WriteData *wd, Camera *cam, const void *id_address)
write_animdata(wd, cam->adt);
}
- for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
writestruct(wd, DATA, CameraBGImage, 1, bgpic);
}
}
@@ -2048,7 +2045,7 @@ static void write_mball(WriteData *wd, MetaBall *mb, const void *id_address)
write_animdata(wd, mb->adt);
}
- for (MetaElem *ml = mb->elems.first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) {
writestruct(wd, DATA, MetaElem, 1, ml);
}
}
@@ -2079,10 +2076,10 @@ static void write_curve(WriteData *wd, Curve *cu, const void *id_address)
}
else {
/* is also the order of reading */
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
writestruct(wd, DATA, Nurb, 1, nu);
}
- for (Nurb *nu = cu->nurb.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->type == CU_BEZIER) {
writestruct(wd, DATA, BezTriple, nu->pntsu, nu->bezt);
}
@@ -2327,7 +2324,7 @@ static void write_image(WriteData *wd, Image *ima, const void *id_address)
write_previews(wd, ima->preview);
- for (ImageView *iv = ima->views.first; iv; iv = iv->next) {
+ LISTBASE_FOREACH (ImageView *, iv, &ima->views) {
writestruct(wd, DATA, ImageView, 1, iv);
}
writestruct(wd, DATA, Stereo3dFormat, 1, ima->stereo3d_format);
@@ -2450,11 +2447,11 @@ static void write_collection_nolib(WriteData *wd, Collection *collection)
/* Shared function for collection data-blocks and scene master collection. */
write_previews(wd, collection->preview);
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
writestruct(wd, DATA, CollectionObject, 1, cob);
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
writestruct(wd, DATA, CollectionChild, 1, child);
}
@@ -2532,7 +2529,7 @@ static void write_paint(WriteData *wd, Paint *p)
static void write_layer_collections(WriteData *wd, ListBase *lb)
{
- for (LayerCollection *lc = lb->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, lb) {
writestruct(wd, DATA, LayerCollection, 1, lc);
write_layer_collections(wd, &lc->layer_collections);
@@ -2548,12 +2545,11 @@ static void write_view_layer(WriteData *wd, ViewLayer *view_layer)
IDP_WriteProperty(view_layer->id_properties, wd);
}
- for (FreestyleModuleConfig *fmc = view_layer->freestyle_config.modules.first; fmc;
- fmc = fmc->next) {
+ LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &view_layer->freestyle_config.modules) {
writestruct(wd, DATA, FreestyleModuleConfig, 1, fmc);
}
- for (FreestyleLineSet *fls = view_layer->freestyle_config.linesets.first; fls; fls = fls->next) {
+ LISTBASE_FOREACH (FreestyleLineSet *, fls, &view_layer->freestyle_config.linesets) {
writestruct(wd, DATA, FreestyleLineSet, 1, fls);
}
write_layer_collections(wd, &view_layer->layer_collections);
@@ -2739,7 +2735,7 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address)
SEQ_END;
/* new; meta stack too, even when its nasty restore code */
- for (MetaStack *ms = ed->metastack.first; ms; ms = ms->next) {
+ LISTBASE_FOREACH (MetaStack *, ms, &ed->metastack) {
writestruct(wd, DATA, MetaStack, 1, ms);
}
}
@@ -2758,17 +2754,17 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address)
}
/* writing dynamic list of TimeMarkers to the blend file */
- for (TimeMarker *marker = sce->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &sce->markers) {
writestruct(wd, DATA, TimeMarker, 1, marker);
}
/* writing dynamic list of TransformOrientations to the blend file */
- for (TransformOrientation *ts = sce->transform_spaces.first; ts; ts = ts->next) {
+ LISTBASE_FOREACH (TransformOrientation *, ts, &sce->transform_spaces) {
writestruct(wd, DATA, TransformOrientation, 1, ts);
}
/* writing MultiView to the blend file */
- for (SceneRenderView *srv = sce->r.views.first; srv; srv = srv->next) {
+ LISTBASE_FOREACH (SceneRenderView *, srv, &sce->r.views) {
writestruct(wd, DATA, SceneRenderView, 1, srv);
}
@@ -2794,7 +2790,7 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address)
write_previews(wd, sce->preview);
write_curvemapping_curves(wd, &sce->r.mblur_shutter_curve);
- for (ViewLayer *view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &sce->view_layers) {
write_view_layer(wd, view_layer);
}
@@ -2947,7 +2943,7 @@ static void write_soops(WriteData *wd, SpaceOutliner *so)
static void write_panel_list(WriteData *wd, ListBase *lb)
{
- for (Panel *pa = lb->first; pa; pa = pa->next) {
+ LISTBASE_FOREACH (Panel *, pa, lb) {
writestruct(wd, DATA, Panel, 1, pa);
write_panel_list(wd, &pa->children);
}
@@ -2955,27 +2951,25 @@ static void write_panel_list(WriteData *wd, ListBase *lb)
static void write_area_regions(WriteData *wd, ScrArea *area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
write_region(wd, region, area->spacetype);
write_panel_list(wd, &region->panels);
- for (PanelCategoryStack *pc_act = region->panels_category_active.first; pc_act;
- pc_act = pc_act->next) {
+ LISTBASE_FOREACH (PanelCategoryStack *, pc_act, &region->panels_category_active) {
writestruct(wd, DATA, PanelCategoryStack, 1, pc_act);
}
- for (uiList *ui_list = region->ui_lists.first; ui_list; ui_list = ui_list->next) {
+ LISTBASE_FOREACH (uiList *, ui_list, &region->ui_lists) {
write_uilist(wd, ui_list);
}
- for (uiPreview *ui_preview = region->ui_previews.first; ui_preview;
- ui_preview = ui_preview->next) {
+ LISTBASE_FOREACH (uiPreview *, ui_preview, &region->ui_previews) {
writestruct(wd, DATA, uiPreview, 1, ui_preview);
}
}
- for (SpaceLink *sl = area->spacedata.first; sl; sl = sl->next) {
- for (ARegion *region = sl->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+ LISTBASE_FOREACH (ARegion *, region, &sl->regionbase) {
write_region(wd, region, sl->spacetype);
}
@@ -3088,7 +3082,7 @@ static void write_area_map(WriteData *wd, ScrAreaMap *area_map)
{
writelist(wd, DATA, ScrVert, &area_map->vertbase);
writelist(wd, DATA, ScrEdge, &area_map->edgebase);
- for (ScrArea *area = area_map->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &area_map->areabase) {
area->butspacetype = area->spacetype; /* Just for compatibility, will be reset below. */
writestruct(wd, DATA, ScrArea, 1, area);
@@ -3109,7 +3103,7 @@ static void write_windowmanager(WriteData *wd, wmWindowManager *wm, const void *
write_iddata(wd, &wm->id);
write_wm_xr_data(wd, &wm->xr);
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
#ifndef WITH_GLOBAL_AREA_WRITING
/* Don't write global areas yet, while we make changes to them. */
ScrAreaMap global_areas = win->global_areas;
@@ -3165,7 +3159,7 @@ static void write_bone(WriteData *wd, Bone *bone)
}
/* Write Children */
- for (Bone *cbone = bone->childbase.first; cbone; cbone = cbone->next) {
+ LISTBASE_FOREACH (Bone *, cbone, &bone->childbase) {
write_bone(wd, cbone);
}
}
@@ -3188,7 +3182,7 @@ static void write_armature(WriteData *wd, bArmature *arm, const void *id_address
}
/* Direct data */
- for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
write_bone(wd, bone);
}
}
@@ -3214,11 +3208,11 @@ static void write_text(WriteData *wd, Text *text, const void *id_address)
if (!(text->flags & TXT_ISEXT)) {
/* now write the text data, in two steps for optimization in the readfunction */
- for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) {
+ LISTBASE_FOREACH (TextLine *, tmp, &text->lines) {
writestruct(wd, DATA, TextLine, 1, tmp);
}
- for (TextLine *tmp = text->lines.first; tmp; tmp = tmp->next) {
+ LISTBASE_FOREACH (TextLine *, tmp, &text->lines) {
writedata(wd, DATA, tmp->len + 1, tmp->line);
}
}
@@ -3777,7 +3771,7 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace, const void *id_
writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations);
writelist(wd, DATA, wmOwnerID, &workspace->owner_ids);
writelist(wd, DATA, bToolRef, &workspace->tools);
- for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
if (tref->properties) {
IDP_WriteProperty(tref->properties, wd);
}
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index d33f4e0a1d6..1bf419f4461 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -1083,12 +1083,12 @@ void BM_select_history_merge_from_targetmap(
{
#ifdef DEBUG
- for (BMEditSelection *ese = bm->selected.first; ese; ese = ese->next) {
+ LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
BLI_assert(BM_ELEM_API_FLAG_TEST(ese->ele, _FLAG_OVERLAP) == 0);
}
#endif
- for (BMEditSelection *ese = bm->selected.first; ese; ese = ese->next) {
+ LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
BM_ELEM_API_FLAG_ENABLE(ese->ele, _FLAG_OVERLAP);
/* Only loop when (use_chain == true). */
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index ff618142bfa..933223c3337 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -2593,7 +2593,7 @@ void BM_mesh_rebuild(BMesh *bm,
}
}
- for (BMEditSelection *ese = bm->selected.first; ese; ese = ese->next) {
+ LISTBASE_FOREACH (BMEditSelection *, ese, &bm->selected) {
switch (ese->htype) {
case BM_VERT:
if (remap & BM_VERT) {
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index ba6aacf00d7..10ad8f3f1be 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -2187,7 +2187,7 @@ void EEVEE_particle_hair_cache_populate(EEVEE_Data *vedata,
if (ob->type == OB_MESH) {
if (ob != draw_ctx->object_edit) {
- for (ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
if (md->type != eModifierType_ParticleSystem) {
continue;
}
diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c
index b97766d1ca2..63c96ac8c25 100644
--- a/source/blender/draw/engines/eevee/eevee_volumes.c
+++ b/source/blender/draw/engines/eevee/eevee_volumes.c
@@ -852,7 +852,7 @@ void EEVEE_volumes_resolve(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda
void EEVEE_volumes_free_smoke_textures(void)
{
/* Free Smoke Textures after rendering */
- for (LinkData *link = e_data.smoke_domains.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &e_data.smoke_domains) {
FluidModifierData *mmd = (FluidModifierData *)link->data;
GPU_free_smoke(mmd);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 4963221743f..50e4e8d2ec4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -744,8 +744,8 @@ static void GPENCIL_draw_scene_depth_only(void *ved)
GPU_framebuffer_bind(dfbl->depth_only_fb);
}
- for (GPENCIL_tObject *ob = pd->tobjects.first; ob; ob = ob->next) {
- for (GPENCIL_tLayer *layer = ob->layers.first; layer; layer = layer->next) {
+ LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->tobjects) {
+ LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) {
DRW_draw_pass(layer->geom_ps);
}
}
@@ -826,7 +826,7 @@ static void GPENCIL_draw_object(GPENCIL_Data *vedata, GPENCIL_tObject *ob)
GPU_framebuffer_multi_clear(fb_object, clear_cols);
}
- for (GPENCIL_tLayer *layer = ob->layers.first; layer; layer = layer->next) {
+ LISTBASE_FOREACH (GPENCIL_tLayer *, layer, &ob->layers) {
if (layer->mask_bits) {
gpencil_draw_mask(vedata, ob, layer);
}
@@ -847,7 +847,7 @@ static void GPENCIL_draw_object(GPENCIL_Data *vedata, GPENCIL_tObject *ob)
}
}
- for (GPENCIL_tVfx *vfx = ob->vfx.first; vfx; vfx = vfx->next) {
+ LISTBASE_FOREACH (GPENCIL_tVfx *, vfx, &ob->vfx) {
GPU_framebuffer_bind(*(vfx->target_fb));
DRW_draw_pass(vfx->vfx_ps);
}
@@ -893,7 +893,7 @@ static void GPENCIL_fast_draw_end(GPENCIL_Data *vedata)
pd->snapshot_buffer_dirty = false;
}
/* Draw the sbuffer stroke(s). */
- for (GPENCIL_tObject *ob = pd->sbuffer_tobjects.first; ob; ob = ob->next) {
+ LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->sbuffer_tobjects) {
GPENCIL_draw_object(vedata, ob);
}
}
@@ -934,7 +934,7 @@ void GPENCIL_draw_scene(void *ved)
GPU_framebuffer_multi_clear(fbl->gpencil_fb, clear_cols);
}
- for (GPENCIL_tObject *ob = pd->tobjects.first; ob; ob = ob->next) {
+ LISTBASE_FOREACH (GPENCIL_tObject *, ob, &pd->tobjects) {
GPENCIL_draw_object(vedata, ob);
}
diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c
index 19b88682c1d..566c8cad528 100644
--- a/source/blender/draw/engines/overlay/overlay_extra.c
+++ b/source/blender/draw/engines/overlay/overlay_extra.c
@@ -913,7 +913,7 @@ static void camera_view3d_reconstruction(OVERLAY_ExtraCallBuffers *cb,
}
ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object);
- for (MovieTrackingTrack *track = tracksbase->first; track; track = track->next) {
+ LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
if ((track->flag & TRACK_HAS_BUNDLE) == 0) {
continue;
}
diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c
index 7eda342d700..45d218b4959 100644
--- a/source/blender/draw/engines/overlay/overlay_image.c
+++ b/source/blender/draw/engines/overlay/overlay_image.c
@@ -313,7 +313,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
float norm_obmat[4][4];
normalize_m4_m4(norm_obmat, ob->obmat);
- for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
if (bgpic->flag & CAM_BGIMG_FLAG_DISABLED) {
continue;
}
diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c
index 997cc0fbbdb..531e1faf715 100644
--- a/source/blender/draw/engines/overlay/overlay_motion_path.c
+++ b/source/blender/draw/engines/overlay/overlay_motion_path.c
@@ -212,7 +212,7 @@ void OVERLAY_motion_path_cache_populate(OVERLAY_Data *vedata, Object *ob)
if (ob->type == OB_ARMATURE) {
if (OVERLAY_armature_is_pose_mode(ob, draw_ctx)) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->mpath) {
motion_path_cache(vedata, ob, pchan, &ob->pose->avs, pchan->mpath);
}
diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c
index d505902d69c..21cb567aaae 100644
--- a/source/blender/draw/engines/workbench/workbench_volume.c
+++ b/source/blender/draw/engines/workbench/workbench_volume.c
@@ -291,7 +291,7 @@ void workbench_volume_draw_finish(WORKBENCH_Data *vedata)
* modifier we don't want them to take precious VRAM if the
* modifier is not used for display. We should share them for
* all viewport in a redraw at least. */
- for (LinkData *link = wpd->smoke_domains.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &wpd->smoke_domains) {
FluidModifierData *mmd = (FluidModifierData *)link->data;
GPU_free_smoke(mmd);
}
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index 33571d82079..4f03ab04862 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -77,7 +77,7 @@ static void curve_render_overlay_verts_edges_len_get(ListBase *lb,
BLI_assert(r_vert_len || r_edge_len);
int vert_len = 0;
int edge_len = 0;
- for (Nurb *nu = lb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, lb) {
if (nu->bezt) {
vert_len += nu->pntsu * 3;
/* 2x handles per point*/
@@ -107,7 +107,7 @@ static void curve_render_wire_verts_edges_len_get(const CurveCache *ob_curve_cac
int vert_len = 0;
int edge_len = 0;
int curve_len = 0;
- for (const BevList *bl = ob_curve_cache->bev.first; bl; bl = bl->next) {
+ LISTBASE_FOREACH (const BevList *, bl, &ob_curve_cache->bev) {
if (bl->nr > 0) {
const bool is_cyclic = bl->poly != -1;
edge_len += (is_cyclic) ? bl->nr : bl->nr - 1;
@@ -115,7 +115,7 @@ static void curve_render_wire_verts_edges_len_get(const CurveCache *ob_curve_cac
curve_len += 1;
}
}
- for (const DispList *dl = ob_curve_cache->disp.first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, &ob_curve_cache->disp) {
if (ELEM(dl->type, DL_SEGM, DL_POLY)) {
BLI_assert(dl->parts == 1);
const bool is_cyclic = dl->type == DL_POLY;
@@ -315,7 +315,7 @@ static void curve_cd_calc_used_gpu_layers(int *cd_layers,
}
ListBase gpu_attrs = GPU_material_attributes(gpumat);
- for (GPUMaterialAttribute *gpu_attr = gpu_attrs.first; gpu_attr; gpu_attr = gpu_attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) {
const char *name = gpu_attr->name;
int type = gpu_attr->type;
@@ -566,7 +566,7 @@ static void curve_create_curves_pos(CurveRenderData *rdata, GPUVertBuf *vbo_curv
GPU_vertbuf_data_alloc(vbo_curves_pos, vert_len);
int v_idx = 0;
- for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) {
+ LISTBASE_FOREACH (const BevList *, bl, &rdata->ob_curve_cache->bev) {
if (bl->nr <= 0) {
continue;
}
@@ -575,7 +575,7 @@ static void curve_create_curves_pos(CurveRenderData *rdata, GPUVertBuf *vbo_curv
GPU_vertbuf_attr_set(vbo_curves_pos, attr_id.pos, v_idx, bevp->vec);
}
}
- for (const DispList *dl = rdata->ob_curve_cache->disp.first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, &rdata->ob_curve_cache->disp) {
if (ELEM(dl->type, DL_SEGM, DL_POLY)) {
for (int i = 0; i < dl->nr; v_idx++, i++) {
GPU_vertbuf_attr_set(vbo_curves_pos, attr_id.pos, v_idx, &((float(*)[3])dl->verts)[i]);
@@ -599,7 +599,7 @@ static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_c
GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len);
int v_idx = 0;
- for (const BevList *bl = rdata->ob_curve_cache->bev.first; bl; bl = bl->next) {
+ LISTBASE_FOREACH (const BevList *, bl, &rdata->ob_curve_cache->bev) {
if (bl->nr <= 0) {
continue;
}
@@ -613,7 +613,7 @@ static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_c
GPU_indexbuf_add_primitive_restart(&elb);
v_idx += bl->nr;
}
- for (const DispList *dl = rdata->ob_curve_cache->disp.first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, &rdata->ob_curve_cache->disp) {
if (ELEM(dl->type, DL_SEGM, DL_POLY)) {
const bool is_cyclic = dl->type == DL_POLY;
if (is_cyclic) {
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index 24a28022b70..e09f78aa51f 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -72,7 +72,7 @@ static int dl_tri_len(const DispList *dl)
static int curve_render_surface_vert_len_get(const ListBase *lb)
{
int vert_len = 0;
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
vert_len += dl_vert_len(dl);
}
return vert_len;
@@ -81,7 +81,7 @@ static int curve_render_surface_vert_len_get(const ListBase *lb)
static int curve_render_surface_tri_len_get(const ListBase *lb)
{
int tri_len = 0;
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
tri_len += dl_tri_len(dl);
}
return tri_len;
@@ -193,7 +193,7 @@ void DRW_displist_vertbuf_create_pos_and_nor(ListBase *lb, GPUVertBuf *vbo)
BKE_displist_normals_add(lb);
int vbo_len_used = 0;
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
const bool ndata_is_single = dl->type == DL_INDEX3;
if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
const float *fp_co = dl->verts;
@@ -263,7 +263,7 @@ void DRW_displist_indexbuf_create_triangles_in_order(ListBase *lb, GPUIndexBuf *
GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len);
int ofs = 0;
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
displist_indexbufbuilder_set((SetTriIndicesFn *)GPU_indexbuf_add_tri_verts,
(SetTriIndicesFn *)GPU_indexbuf_add_tri_verts,
&elb,
@@ -290,7 +290,7 @@ void DRW_displist_indexbuf_create_triangles_loop_split_by_material(ListBase *lb,
/* calc each index buffer builder */
uint v_idx = 0;
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
v_idx = displist_indexbufbuilder_tess_set((SetTriIndicesFn *)GPU_indexbuf_add_tri_verts,
(SetTriIndicesFn *)GPU_indexbuf_add_tri_verts,
&elb[dl->col],
@@ -328,7 +328,7 @@ void DRW_displist_indexbuf_create_lines_in_order(ListBase *lb, GPUIndexBuf *ibo)
GPU_indexbuf_init(&elb, GPU_PRIM_LINES, tri_len * 3, vert_len);
int ofs = 0;
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
displist_indexbufbuilder_set(
set_overlay_wires_tri_indices, set_overlay_wires_quad_tri_indices, &elb, dl, ofs);
ofs += dl_vert_len(dl);
@@ -508,7 +508,7 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb,
BKE_displist_normals_add(lb);
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
const bool is_smooth = (dl->rt & CU_SMOOTH) != 0;
if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
const float(*verts)[3] = (float(*)[3])dl->verts;
@@ -780,7 +780,7 @@ void DRW_displist_indexbuf_create_edges_adjacency_lines(struct ListBase *lb,
/* pack values to pass to `set_edges_adjacency_lines_indices` function. */
void *thunk[3] = {&elb, eh, r_is_manifold};
int v_idx = 0;
- for (const DispList *dl = lb->first; dl; dl = dl->next) {
+ LISTBASE_FOREACH (const DispList *, dl, lb) {
displist_indexbufbuilder_set((SetTriIndicesFn *)set_edges_adjacency_lines_indices,
(SetTriIndicesFn *)set_edges_adjacency_lines_indices,
thunk,
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index a4b88d99a3c..308d87f1385 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -144,7 +144,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Mesh *me,
GPUMaterial *gpumat = gpumat_array[i];
if (gpumat) {
ListBase gpu_attrs = GPU_material_attributes(gpumat);
- for (GPUMaterialAttribute *gpu_attr = gpu_attrs.first; gpu_attr; gpu_attr = gpu_attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, gpu_attr, &gpu_attrs) {
const char *name = gpu_attr->name;
int type = gpu_attr->type;
int layer = -1;
diff --git a/source/blender/draw/intern/draw_cache_impl_volume.c b/source/blender/draw/intern/draw_cache_impl_volume.c
index c64817413b8..a7562b1b8ea 100644
--- a/source/blender/draw/intern/draw_cache_impl_volume.c
+++ b/source/blender/draw/intern/draw_cache_impl_volume.c
@@ -124,7 +124,7 @@ static void volume_batch_cache_clear(Volume *volume)
return;
}
- for (DRWVolumeGrid *grid = cache->grids.first; grid; grid = grid->next) {
+ LISTBASE_FOREACH (DRWVolumeGrid *, grid, &cache->grids) {
MEM_SAFE_FREE(grid->name);
DRW_TEXTURE_FREE_SAFE(grid->texture);
}
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 280e82ef473..1434cac5f97 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -690,8 +690,7 @@ void **DRW_duplidata_get(void *vedata)
void *DRW_view_layer_engine_data_get(DrawEngineType *engine_type)
{
- for (ViewLayerEngineData *sled = DST.draw_ctx.view_layer->drawdata.first; sled;
- sled = sled->next) {
+ LISTBASE_FOREACH (ViewLayerEngineData *, sled, &DST.draw_ctx.view_layer->drawdata) {
if (sled->engine_type == engine_type) {
return sled->storage;
}
@@ -922,7 +921,7 @@ void DRW_cache_free_old_batches(Main *bmain)
static void drw_engines_init(void)
{
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
PROFILE_START(stime);
@@ -966,7 +965,7 @@ static void drw_engines_world_update(Scene *scene)
return;
}
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
@@ -1032,7 +1031,7 @@ static void drw_engines_cache_finish(void)
static void drw_engines_draw_scene(void)
{
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
PROFILE_START(stime);
@@ -1055,7 +1054,7 @@ static void drw_engines_draw_scene(void)
static void drw_engines_draw_text(void)
{
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
PROFILE_START(stime);
@@ -1071,7 +1070,7 @@ static void drw_engines_draw_text(void)
/* Draw render engine info. */
void DRW_draw_region_engine_info(int xoffset, int yoffset)
{
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
DrawEngineType *engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
@@ -1178,7 +1177,7 @@ static void drw_engines_data_validate(void)
void **engine_handle_array = BLI_array_alloca(engine_handle_array, enabled_engines + 1);
int i = 0;
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
DrawEngineType *engine = link->data;
engine_handle_array[i++] = engine;
}
@@ -1245,7 +1244,7 @@ void DRW_notify_view_update(const DRWUpdateContext *update_ctx)
drw_engines_enable(view_layer, engine_type, gpencil_engine_needed);
drw_engines_data_validate();
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
DrawEngineType *draw_engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(draw_engine);
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 50193dde7ee..0544bb3c49b 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1300,7 +1300,7 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp,
ListBase textures = GPU_material_textures(material);
/* Bind all textures needed by the material. */
- for (GPUMaterialTexture *tex = textures.first; tex; tex = tex->next) {
+ LISTBASE_FOREACH (GPUMaterialTexture *, tex, &textures) {
if (tex->ima) {
/* Image */
if (tex->tiled_mapping_name[0]) {
@@ -1903,7 +1903,7 @@ DRWPass *DRW_pass_create(const char *name, DRWState state)
bool DRW_pass_is_empty(DRWPass *pass)
{
- for (DRWShadingGroup *shgroup = pass->shgroups.first; shgroup; shgroup = shgroup->next) {
+ LISTBASE_FOREACH (DRWShadingGroup *, shgroup, &pass->shgroups) {
if (!DRW_shgroup_is_empty(shgroup)) {
return false;
}
@@ -1930,7 +1930,7 @@ void DRW_pass_foreach_shgroup(DRWPass *pass,
void (*callback)(void *userData, DRWShadingGroup *shgrp),
void *userData)
{
- for (DRWShadingGroup *shgroup = pass->shgroups.first; shgroup; shgroup = shgroup->next) {
+ LISTBASE_FOREACH (DRWShadingGroup *, shgroup, &pass->shgroups) {
callback(userData, shgroup);
}
}
diff --git a/source/blender/draw/intern/draw_manager_profiling.c b/source/blender/draw/intern/draw_manager_profiling.c
index b4bcfd3f600..57887c11c02 100644
--- a/source/blender/draw/intern/draw_manager_profiling.c
+++ b/source/blender/draw/intern/draw_manager_profiling.c
@@ -251,7 +251,7 @@ void DRW_stats_draw(const rcti *rect)
/* Engines rows */
char time_to_txt[16];
- for (LinkData *link = DST.enabled_engines.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &DST.enabled_engines) {
u = 0;
DrawEngineType *engine = link->data;
ViewportEngineData *data = drw_viewport_engine_data_ensure(engine);
diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c
index 89884d58099..b451cfb1d05 100644
--- a/source/blender/draw/intern/draw_manager_shader.c
+++ b/source/blender/draw/intern/draw_manager_shader.c
@@ -249,7 +249,7 @@ void DRW_deferred_shader_remove(GPUMaterial *mat)
/* No job running, do not create a new one by calling WM_jobs_get. */
continue;
}
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
wmJob *wm_job = WM_jobs_get(
wm, win, scene, "Shaders Compilation", WM_JOB_PROGRESS, WM_JOB_TYPE_SHADER_COMPILATION);
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 5ea5b2aa1f6..38a19e85661 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -3139,7 +3139,7 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads,
size_t num_bases = 0;
Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases");
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (animdata_filter_base_is_ok(ads, base, filter_mode)) {
sorted_bases[num_bases++] = base;
}
@@ -3233,7 +3233,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac,
/* Filter and add contents of each base (i.e. object) without them sorting first
* NOTE: This saves performance in cases where order doesn't matter
*/
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (animdata_filter_base_is_ok(ads, base, filter_mode)) {
/* since we're still here, this object should be usable */
items += animdata_filter_dopesheet_ob(ac, anim_data, ads, base, filter_mode);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 5523fd67dca..46566feea91 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -358,7 +358,7 @@ void ED_markers_deselect_all(ListBase *markers, int action)
action = ED_markers_get_first_selected(markers) ? SEL_DESELECT : SEL_SELECT;
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (action == SEL_SELECT) {
marker->flag |= SELECT;
}
@@ -599,14 +599,14 @@ void ED_markers_draw(const bContext *C, int flag)
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
/* Separate loops in order to draw selected markers on top */
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if ((marker->flag & SELECT) == 0) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
}
}
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (marker->flag & SELECT) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, region->winy);
@@ -1156,7 +1156,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot)
static void deselect_markers(ListBase *markers)
{
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
marker->flag &= ~SELECT;
}
}
@@ -1373,7 +1373,7 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op)
ED_markers_deselect_all(markers, SEL_DESELECT);
}
- for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, markers) {
if (BLI_rctf_isect_x(&rect, marker->frame)) {
SET_FLAG_FROM_TEST(marker->flag, select, SELECT);
}
@@ -1646,7 +1646,7 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op)
BLI_addtail(markers, marker);
/* deselect all others, so that the user can then move it without problems */
- for (TimeMarker *m = markers->first; m; m = m->next) {
+ LISTBASE_FOREACH (TimeMarker *, m, markers) {
if (m != marker) {
m->flag &= ~SELECT;
}
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index a4ecd346a01..4c10c66dfa6 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -228,7 +228,7 @@ static void motionpath_get_global_framerange(ListBase *targets, int *r_sfra, int
{
*r_sfra = INT_MAX;
*r_efra = INT_MIN;
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
*r_sfra = min_ii(*r_sfra, mpt->mpath->start_frame);
*r_efra = max_ii(*r_efra, mpt->mpath->end_frame);
}
@@ -348,7 +348,7 @@ static void motionpath_calculate_update_range(MPathTarget *mpt,
static void motionpath_free_free_tree_data(ListBase *targets)
{
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
BLI_dlrbTree_free(&mpt->keys);
}
}
@@ -412,7 +412,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
DEG_make_inactive(depsgraph);
}
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
mpt->ob_eval = DEG_get_evaluated_object(depsgraph, mpt->ob);
AnimData *adt = BKE_animdata_from_id(&mpt->ob_eval->id);
@@ -492,7 +492,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph,
}
/* clear recalc flags from targets */
- for (MPathTarget *mpt = targets->first; mpt; mpt = mpt->next) {
+ LISTBASE_FOREACH (MPathTarget *, mpt, targets) {
bMotionPath *mpath = mpt->mpath;
/* get pointer to animviz settings for each target */
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index eae86d4990c..b921ba039be 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -506,14 +506,14 @@ static void update_keyblocks(DLRBT_Tree *keys, BezTriple *bezt, int bezt_len)
/* Find the curve count */
int max_curve = 0;
- for (ActKeyColumn *col = keys->first; col; col = col->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, col, keys) {
max_curve = MAX2(max_curve, col->totcurve);
}
/* Propagate blocks to inserted keys */
ActKeyColumn *prev_ready = NULL;
- for (ActKeyColumn *col = keys->first; col; col = col->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, col, keys) {
/* Pre-existing column. */
if (col->totcurve > 0) {
prev_ready = col;
@@ -731,7 +731,7 @@ static void draw_keylist(View2D *v2d,
ipo_color_mix[3] *= 0.5f;
uint block_len = 0;
- for (ActKeyColumn *ab = keys->first; ab; ab = ab->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ab, keys) {
if (actkeyblock_get_valid_hold(ab)) {
block_len++;
}
@@ -747,7 +747,7 @@ static void draw_keylist(View2D *v2d,
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
immBegin(GPU_PRIM_TRIS, 6 * block_len);
- for (ActKeyColumn *ab = keys->first; ab; ab = ab->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ab, keys) {
int valid_hold = actkeyblock_get_valid_hold(ab);
if (valid_hold != 0) {
if ((valid_hold & ACTKEYBLOCK_FLAG_STATIC_HOLD) == 0) {
@@ -792,7 +792,7 @@ static void draw_keylist(View2D *v2d,
if (keys) {
/* count keys */
uint key_len = 0;
- for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ak, keys) {
/* Optimization: if keyframe doesn't appear within 5 units (screenspace)
* in visible area, don't draw.
* This might give some improvements,
@@ -823,7 +823,7 @@ static void draw_keylist(View2D *v2d,
short handle_type = KEYFRAME_HANDLE_NONE, extreme_type = KEYFRAME_EXTREME_NONE;
- for (ActKeyColumn *ak = keys->first; ak; ak = ak->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ak, keys) {
if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax)) {
if (show_ipo) {
handle_type = ak->handle_type;
@@ -1154,7 +1154,7 @@ void cachefile_to_keylist(bDopeSheet *ads,
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* loop through each F-Curve, grabbing the keyframes */
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
fcurve_to_keylist(ale->adt, ale->data, keys, saction_flag);
}
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index 1105633f47e..f6875a6e158 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -341,7 +341,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob)
GHash *name_map = BLI_ghash_str_new(__func__);
- for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_src, editbones) {
EditBone *ebone_dst = ebone_src->temp.ebone;
if (!ebone_dst) {
ebone_dst = ED_armature_ebone_get_mirrored(editbones, ebone_src);
@@ -351,7 +351,7 @@ void postEditBoneDuplicate(struct ListBase *editbones, Object *ob)
}
}
- for (EditBone *ebone_src = editbones->first; ebone_src; ebone_src = ebone_src->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_src, editbones) {
EditBone *ebone_dst = ebone_src->temp.ebone;
if (ebone_dst) {
bPoseChannel *pchan_src = BKE_pose_channel_find_name(ob->pose, ebone_src->name);
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 9a640952253..8a7afe13a2f 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -499,7 +499,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
/* Roll func is a callback which assumes that all is well. */
ebone->roll = roll;
@@ -508,7 +508,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op)
}
if (arm->flag & ARM_MIRROR_EDIT) {
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone);
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
@@ -1189,13 +1189,13 @@ static int armature_split_exec(bContext *C, wmOperator *UNUSED(op))
Object *ob = objects[ob_index];
bArmature *arm = ob->data;
- for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (EditBone *, bone, arm->edbo) {
if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)) {
bone->parent = NULL;
bone->flag &= ~BONE_CONNECTED;
}
}
- for (EditBone *bone = arm->edbo->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (EditBone *, bone, arm->edbo) {
ED_armature_ebone_select_set(bone, (bone->flag & BONE_SELECTED) != 0);
}
@@ -1508,7 +1508,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone)) {
if ((ebone->flag & BONE_SELECTED) != invert) {
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
@@ -1567,7 +1567,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_HIDDEN_A) {
if (!(ebone->flag & BONE_UNSELECTABLE)) {
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index b2c3d951b34..aa1bceb2674 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -317,8 +317,7 @@ void ED_armature_bone_rename(Main *bmain,
}
}
- for (GpencilModifierData *gp_md = ob->greasepencil_modifiers.first; gp_md;
- gp_md = gp_md->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, gp_md, &ob->greasepencil_modifiers) {
switch (gp_md->type) {
case eGpencilModifierType_Armature: {
ArmatureGpencilModifierData *mmd = (ArmatureGpencilModifierData *)gp_md;
@@ -415,7 +414,7 @@ void ED_armature_bones_flip_names(Main *bmain,
/* First pass: generate flip names, and blindly rename.
* If rename did not yield expected result,
* store both bone's name and expected flipped one into temp list for second pass. */
- for (LinkData *link = bones_names->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, bones_names) {
char name_flip[MAXBONENAME];
char *name = link->data;
@@ -470,7 +469,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op)
ListBase bones_names = {NULL};
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_SELECTED) {
BLI_addtail(&bones_names, BLI_genericNodeN(ebone->name));
@@ -557,7 +556,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op)
continue;
}
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone)) {
/* We first need to do the flipped bone, then the original one.
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index c592287c967..644e466e904 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -569,7 +569,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec
if (is_select == (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_SELECTED))) {
/* clear the bone->parent var of any bone that had this as its parent */
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
if (ebo->parent == curbone) {
ebo->parent = NULL;
/* this is needed to prevent random crashes with in ED_armature_from_edit */
@@ -579,7 +579,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec
}
/* clear the pchan->parent var of any pchan that had this as its parent */
- for (bPoseChannel *pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchn, &ob->pose->chanbase) {
if (pchn->parent == pchan) {
pchn->parent = NULL;
}
@@ -630,7 +630,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
bArmature *arm_old = ob_old->data;
bool has_selected_bone = false;
bool has_selected_any = false;
- for (EditBone *ebone = arm_old->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm_old->edbo) {
if (EBONE_VISIBLE(arm_old, ebone)) {
if (ebone->flag & BONE_SELECTED) {
has_selected_bone = true;
@@ -836,7 +836,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
bool is_active_only_selected = false;
if (actbone->flag & BONE_SELECTED) {
is_active_only_selected = true;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
if (ebone != actbone) {
is_active_only_selected = false;
@@ -868,7 +868,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
*/
/* Parent selected bones to the active one. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
if (ebone != actbone) {
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
@@ -902,7 +902,7 @@ static int armature_parent_set_invoke(bContext *C,
Object *ob = CTX_data_edit_object(C);
bArmature *arm = ob->data;
EditBone *actbone = arm->act_edbone;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone) && (ebone->flag & BONE_SELECTED)) {
if (ebone != actbone) {
if (ebone->parent != actbone) {
@@ -984,7 +984,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_EDITABLE(ebone)) {
changed = true;
break;
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index 700fe14ade6..4b938fb0072 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -426,12 +426,12 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo
(((ebone)->flag & BONE_CONNECTED) && \
((ebone)->parent ? EBONE_SELECTABLE(arm, (ebone)->parent) : false))
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
ebone->temp.i = 0;
}
/* Select parents. */
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (ebone_iter->temp.i & TOUCH) {
continue;
}
@@ -460,7 +460,7 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo
}
/* Select children. */
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
/* No need to 'touch' this bone as it won't be walked over when scanning up the chain. */
if (!CHECK_PARENT(ebone_iter)) {
continue;
@@ -521,7 +521,7 @@ static int armature_select_linked_exec(bContext *C, wmOperator *op)
bArmature *arm = ob->data;
bool found = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_VISIBLE(arm, ebone) &&
(ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL))) {
ebone->flag |= BONE_DONE;
@@ -591,7 +591,7 @@ static int armature_select_linked_pick_invoke(bContext *C, wmOperator *op, const
}
/* Initialize flags. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
ebone->flag &= ~BONE_DONE;
}
ebone_active->flag |= BONE_DONE;
@@ -848,7 +848,7 @@ bool ED_armature_edit_deselect_all(Object *obedit)
{
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
changed = true;
@@ -861,7 +861,7 @@ bool ED_armature_edit_deselect_all_visible(Object *obedit)
{
bArmature *arm = obedit->data;
bool changed = false;
- for (EditBone *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)) {
if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
@@ -1138,7 +1138,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
/* Initialize flags. */
{
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
/* Flush the parent flag to this bone
* so we don't need to check the parent when adjusting the selection. */
@@ -1160,7 +1160,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
}
/* Apply selection from bone selection flags. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->temp.i != 0) {
int is_ignore_flag = ((ebone->temp.i << 16) & (BONESEL_ROOT | BONESEL_TIP));
int is_inside_flag = (ebone->temp.i & (BONESEL_ROOT | BONESEL_TIP | BONESEL_BONE));
@@ -1180,7 +1180,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
if (changed) {
/* Cleanup flags. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->flag & BONE_DONE) {
SWAP(int, ebone->temp.i, ebone->flag);
ebone->flag |= BONE_DONE;
@@ -1193,7 +1193,7 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op)
}
}
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->flag & BONE_DONE) {
if ((ebone->flag & BONE_CONNECTED) && ebone->parent) {
bool is_parent_tip_changed = (ebone->parent->flag & BONE_TIPSEL) !=
@@ -1539,7 +1539,7 @@ static void select_similar_length(bContext *C, const float thresh)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
const float len_iter = bone_length_squared_worldspace_get(ob, ebone);
if ((len_iter > len_min) && (len_iter < len_max)) {
@@ -1587,7 +1587,7 @@ static void select_similar_direction(bContext *C, const float thresh)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
float dir[3];
bone_direction_worldspace_get(ob, ebone, dir);
@@ -1621,7 +1621,7 @@ static void select_similar_layer(bContext *C)
bArmature *arm = ob->data;
bool changed = false;
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
if (ebone->layer & ebone_act->layer) {
ED_armature_ebone_select_set(ebone, true);
@@ -1661,7 +1661,7 @@ static void select_similar_prefix(bContext *C)
bool changed = false;
/* Find matches */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
char prefix_other[MAXBONENAME];
BLI_string_split_prefix(ebone->name, prefix_other, body_tmp, sizeof(ebone->name));
@@ -1703,7 +1703,7 @@ static void select_similar_suffix(bContext *C)
bool changed = false;
/* Find matches */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
char suffix_other[MAXBONENAME];
BLI_string_split_suffix(ebone->name, body_tmp, suffix_other, sizeof(ebone->name));
@@ -1738,7 +1738,7 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons
}
const char *data_active = (const char *)POINTER_OFFSET(pchan_active, offset);
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (EBONE_SELECTABLE(arm, ebone)) {
const bPoseChannel *pchan = BKE_pose_channel_find_name(obedit->pose, ebone->name);
if (pchan) {
@@ -1773,11 +1773,11 @@ static void select_similar_children(bContext *C)
bArmature *arm = obedit->data;
EditBone *ebone_act = CTX_data_active_bone(C);
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
ebone_iter->temp.ebone = ebone_iter->parent;
}
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
is_ancestor(ebone_iter, ebone_act);
if (ebone_iter->temp.ebone == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) {
@@ -1795,7 +1795,7 @@ static void select_similar_children_immediate(bContext *C)
bArmature *arm = obedit->data;
EditBone *ebone_act = CTX_data_active_bone(C);
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (ebone_iter->parent == ebone_act && EBONE_SELECTABLE(arm, ebone_iter)) {
ED_armature_ebone_select_set(ebone_iter, true);
}
@@ -1815,7 +1815,7 @@ static void select_similar_siblings(bContext *C)
return;
}
- for (EditBone *ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) {
+ LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) {
if (ebone_iter->parent == ebone_act->parent && EBONE_SELECTABLE(arm, ebone_iter)) {
ED_armature_ebone_select_set(ebone_iter, true);
}
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index fe456324d9c..cf7f6699e5e 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -92,7 +92,7 @@ void ED_armature_edit_validate_active(struct bArmature *arm)
void ED_armature_edit_refresh_layer_used(bArmature *arm)
{
arm->layer_used = 0;
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
arm->layer_used |= ebo->layer;
}
}
@@ -142,7 +142,7 @@ void bone_free(bArmature *arm, EditBone *bone)
}
/* Clear references from other edit bones. */
- for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) {
if (ebone->bbone_next == bone) {
ebone->bbone_next = NULL;
}
@@ -472,7 +472,7 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo
void ED_armature_edit_transform_mirror_update(Object *obedit)
{
bArmature *arm = obedit->data;
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
ED_armature_ebone_transform_mirror_update(arm, ebo, true);
}
}
@@ -580,7 +580,7 @@ static EditBone *make_boneList_recursive(ListBase *edbo,
static EditBone *find_ebone_link(ListBase *edbo, Bone *link)
{
if (link != NULL) {
- for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, edbo) {
if (ebone->temp.bone == link) {
return ebone;
}
@@ -596,7 +596,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, struct Bone *actBone)
EditBone *active = make_boneList_recursive(edbo, bones, NULL, actBone);
- for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, edbo) {
Bone *bone = ebone->temp.bone;
/* Convert custom B-Bone handle links. */
diff --git a/source/blender/editors/armature/editarmature_undo.c b/source/blender/editors/armature/editarmature_undo.c
index d3eeb311863..a3a73f8d509 100644
--- a/source/blender/editors/armature/editarmature_undo.c
+++ b/source/blender/editors/armature/editarmature_undo.c
@@ -95,7 +95,7 @@ static void *undoarm_from_editarm(UndoArmature *uarm, bArmature *arm)
ED_armature_ebone_listbase_temp_clear(&uarm->lb);
- for (EditBone *ebone = uarm->lb.first; ebone; ebone = ebone->next) {
+ LISTBASE_FOREACH (EditBone *, ebone, &uarm->lb) {
uarm->undo_size += sizeof(EditBone);
}
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index f29900b0760..8df4f6b7dfc 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -323,7 +323,7 @@ bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility)
{
bArmature *arm = ob->data;
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) {
if (pchan->bone->flag & BONE_SELECTED) {
return true;
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 3be5e033e00..31c89ca9f43 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -333,7 +333,7 @@ static void applyarmature_process_selected_recursive(bArmature *arm,
pstate = &new_pstate;
}
- for (Bone *child = bone->childbase.first; child; child = child->next) {
+ LISTBASE_FOREACH (Bone *, child, &bone->childbase) {
applyarmature_process_selected_recursive(arm, pose, pose_eval, child, selected, pstate);
}
}
@@ -389,7 +389,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
if (use_selected) {
/* The selected only mode requires a recursive walk to handle parent-child relations. */
- for (Bone *bone = arm->bonebase.first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
applyarmature_process_selected_recursive(
arm, pose, ob_eval->pose, bone, &selected_bones, NULL);
}
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 45e278d691c..8984c090a0e 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5168,7 +5168,7 @@ static bool ed_editcurve_extrude(Curve *cu, EditNurb *editnurb, View3D *v3d)
BKE_curve_nurb_vert_active_get(cu, &cu_actnu, &cu_actvert.p);
int act_offset = 0;
- for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
BLI_assert(nu->pntsu > 0);
int i;
int pnt_len = nu->pntsu;
@@ -6775,7 +6775,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
continue;
}
- for (Nurb *nu = editnurb->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (ED_curve_nurb_select_check(v3d, nu)) {
if (!clear) {
nu->flag |= CU_SMOOTH;
diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c
index e009add1acf..9cf61d02677 100644
--- a/source/blender/editors/curve/editcurve_select.c
+++ b/source/blender/editors/curve/editcurve_select.c
@@ -199,7 +199,7 @@ bool ED_curve_nurb_select_all(const Nurb *nu)
bool ED_curve_select_all(EditNurb *editnurb)
{
bool changed = false;
- for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
changed |= ED_curve_nurb_select_all(nu);
}
return changed;
@@ -258,7 +258,7 @@ bool ED_curve_select_check(View3D *v3d, struct EditNurb *editnurb)
bool ED_curve_deselect_all(EditNurb *editnurb)
{
bool changed = false;
- for (Nurb *nu = editnurb->nurbs.first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, &editnurb->nurbs) {
changed |= ED_curve_nurb_deselect_all(nu);
}
return changed;
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 9566495715a..1528c448c0b 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -543,7 +543,7 @@ static bool gpencil_generate_weights_poll(bContext *C)
}
/* need some armature in the view layer */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->type == OB_ARMATURE) {
return true;
}
@@ -630,7 +630,7 @@ static const EnumPropertyItem *gpencil_armatures_enum_itemf(bContext *C,
RNA_enum_item_add(&item, &totitem, &item_tmp);
i++;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (ob->type == OB_ARMATURE) {
item_tmp.identifier = item_tmp.name = ob->id.name + 2;
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 24c3e9a0635..1e49195140c 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -522,7 +522,7 @@ static bool gp_layer_duplicate_object_poll(bContext *C)
}
/* check there are more grease pencil objects */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if ((base->object != ob) && (base->object->type == OB_GPENCIL)) {
return true;
}
@@ -571,7 +571,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
gpl_dst->opacity = gpl_src->opacity;
/* Create all frames. */
- for (bGPDframe *gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf_src, &gpl_src->frames) {
if ((mode == GP_LAYER_COPY_OBJECT_ACT_FRAME) && (gpf_src != gpl_src->actframe)) {
continue;
@@ -581,7 +581,7 @@ static int gp_layer_duplicate_object_exec(bContext *C, wmOperator *op)
bGPDframe *gpf_dst = BKE_gpencil_frame_addnew(gpl_dst, gpf_src->framenum);
/* Copy strokes. */
- for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_src, &gpf_src->strokes) {
/* Make copy of source stroke. */
bGPDstroke *gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
@@ -1184,12 +1184,12 @@ static int gp_merge_layer_exec(bContext *C, wmOperator *op)
/* Collect frames of gpl_current in hash table to avoid O(n^2) lookups */
GHash *gh_frames_cur = BLI_ghash_int_new_ex(__func__, 64);
- for (bGPDframe *gpf = gpl_current->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_current->frames) {
BLI_ghash_insert(gh_frames_cur, POINTER_FROM_INT(gpf->framenum), gpf);
}
/* read all frames from next layer and add any missing in current layer */
- for (bGPDframe *gpf = gpl_next->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_next->frames) {
/* try to find frame in current layer */
bGPDframe *frame = BLI_ghash_lookup(gh_frames_cur, POINTER_FROM_INT(gpf->framenum));
if (!frame) {
@@ -1439,7 +1439,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op)
switch (direction) {
/* Bring to Front */
case GP_STROKE_MOVE_TOP:
- for (LinkData *link = selected.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
gps = link->data;
BLI_remlink(&gpf->strokes, gps);
BLI_addtail(&gpf->strokes, gps);
@@ -1454,7 +1454,7 @@ static int gp_stroke_arrange_exec(bContext *C, wmOperator *op)
break;
/* Send Backward */
case GP_STROKE_MOVE_DOWN:
- for (LinkData *link = selected.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &selected) {
gps = link->data;
BLI_listbase_link_move(&gpf->strokes, gps, -1);
}
@@ -2529,7 +2529,7 @@ static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
/* Fix driver targets */
if (fcu->driver) {
/* Fix driver references to invalid ID's */
- for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &fcu->driver->variables) {
/* Only change the used targets, since the others will need fixing manually anyway. */
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
/* Change the ID's used. */
@@ -2620,7 +2620,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
bGPdata *gpd_src = ob_iter->data;
/* Apply all GP modifiers before */
- for (GpencilModifierData *md = ob_iter->greasepencil_modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (GpencilModifierData *, md, &ob_iter->greasepencil_modifiers) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type);
if (mti->bakeModifier) {
mti->bakeModifier(bmain, depsgraph, md, ob_iter);
@@ -2629,7 +2629,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
/* copy vertex groups to the base one's */
int old_idx = 0;
- for (bDeformGroup *dg = ob_iter->defbase.first; dg; dg = dg->next) {
+ LISTBASE_FOREACH (bDeformGroup *, dg, &ob_iter->defbase) {
bDeformGroup *vgroup = MEM_dupallocN(dg);
int idx = BLI_listbase_count(&ob_active->defbase);
BKE_object_defgroup_unique_name(vgroup, ob_active);
@@ -2681,7 +2681,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
mul_m3_v3(imat, offset_global);
mul_v3_m3v3(offset_local, imat, offset_global);
- for (bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
+ LISTBASE_FOREACH (bGPDlayer *, gpl_src, &gpd_src->layers) {
bGPDlayer *gpl_new = BKE_gpencil_layer_duplicate(gpl_src);
float diff_mat[4][4];
float inverse_diff_mat[4][4];
@@ -2691,7 +2691,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
invert_m4_m4(inverse_diff_mat, diff_mat);
Material *ma_src = NULL;
- for (bGPDframe *gpf = gpl_new->frames.first; gpf; gpf = gpf->next) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl_new->frames) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
/* Reassign material. Look old material and try to find in destination. */
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 14fd54bf287..947da9e7877 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1333,7 +1333,7 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
if (gp_strokes_copypastebuf.first) {
gp_strokes_copypastebuf_colors = BLI_ghash_int_new("GPencil CopyBuf Colors");
GHash *ma_to_name = gp_strokes_copypastebuf_colors_material_to_name_create(bmain);
- for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gp_strokes_copypastebuf) {
if (ED_gpencil_stroke_can_use(C, gps)) {
Material *ma = BKE_object_material_get(ob, gps->mat_nr + 1);
/* Avoid default material. */
diff --git a/source/blender/editors/gpencil/gpencil_ops_versioning.c b/source/blender/editors/gpencil/gpencil_ops_versioning.c
index 96146c60acb..2dd98bb8df1 100644
--- a/source/blender/editors/gpencil/gpencil_ops_versioning.c
+++ b/source/blender/editors/gpencil/gpencil_ops_versioning.c
@@ -117,9 +117,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op)
DEG_relations_tag_update(bmain); /* added object */
/* convert grease pencil palettes (version >= 2.78) to materials and weights */
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor;
- palcolor = palcolor->next) {
+ LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) {
+ LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) {
/* create material slot */
Material *ma = BKE_gpencil_object_material_new(bmain, ob, palcolor->info, NULL);
@@ -168,9 +167,8 @@ static int gpencil_convert_old_files_exec(bContext *C, wmOperator *op)
}
if (is_annotation) {
- for (const bGPDpalette *palette = gpd->palettes.first; palette; palette = palette->next) {
- for (bGPDpalettecolor *palcolor = palette->colors.first; palcolor;
- palcolor = palcolor->next) {
+ LISTBASE_FOREACH (const bGPDpalette *, palette, &gpd->palettes) {
+ LISTBASE_FOREACH (bGPDpalettecolor *, palcolor, &palette->colors) {
/* fix layers */
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* unlock/unhide layer */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 0048811d53a..3d571773bc8 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -2187,7 +2187,7 @@ int ED_gpencil_select_stroke_segment(bGPDlayer *gpl,
/* Save list of strokes to check */
int totstrokes = 0;
- for (bGPDstroke *gps_iter = gpf->strokes.first; gps_iter; gps_iter = gps_iter->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps_iter, &gpf->strokes) {
if (gps_iter->totpoints < 2) {
continue;
}
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, &region->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, &region->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, &region->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, &region->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, &region->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, &region->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, &region->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, &region->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, &region->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, &region->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 != &region->v2d) {
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 88e9c7c3664..bea44ee89f8 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -610,7 +610,7 @@ static void draw_mask_layers(const bContext *C,
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
/* draw curve itself first... */
draw_spline_curve(C, mask_layer, spline, draw_flag, draw_type, is_active, width, height);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index a0ece69bf17..68dfe0d151f 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -1293,12 +1293,12 @@ static int cyclic_toggle_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
spline->flag ^= MASK_SPLINE_CYCLIC;
}
@@ -1371,7 +1371,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
MaskSpline *spline;
int mask_layer_shape_ofs = 0;
@@ -1493,14 +1493,14 @@ static int mask_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
bool changed = false;
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
bool changed_layer = false;
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
BKE_mask_spline_direction_switch(mask_layer, spline);
changed = true;
@@ -1551,14 +1551,14 @@ static int mask_normals_make_consistent_exec(bContext *C, wmOperator *UNUSED(op)
bool changed = false;
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
bool changed_layer = false;
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -1614,12 +1614,12 @@ static int set_handle_type_exec(bContext *C, wmOperator *op)
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -1695,7 +1695,7 @@ static int mask_hide_view_clear_exec(bContext *C, wmOperator *op)
bool changed = false;
const bool select = RNA_boolean_get(op->ptr, "select");
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & OB_RESTRICT_VIEWPORT) {
ED_mask_layer_select_set(mask_layer, select);
@@ -1739,7 +1739,7 @@ static int mask_hide_view_set_exec(bContext *C, wmOperator *op)
const bool unselected = RNA_boolean_get(op->ptr, "unselected");
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
continue;
@@ -1801,12 +1801,12 @@ static int mask_feather_weight_clear_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_SELECT | MASK_RESTRICT_VIEW)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -1935,7 +1935,7 @@ static int mask_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
for (MaskSpline *spline = mask_layer->splines.last; spline; spline = spline->prev) {
MaskSplinePoint *point = spline->points;
int i = 0;
diff --git a/source/blender/editors/mask/mask_relationships.c b/source/blender/editors/mask/mask_relationships.c
index 5c824fef74d..971e1c948c9 100644
--- a/source/blender/editors/mask/mask_relationships.c
+++ b/source/blender/editors/mask/mask_relationships.c
@@ -45,12 +45,12 @@ static int mask_parent_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -137,12 +137,12 @@ static int mask_parent_set_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c
index 8d037258450..a6dece91eb0 100644
--- a/source/blender/editors/mask/mask_select.c
+++ b/source/blender/editors/mask/mask_select.c
@@ -74,7 +74,7 @@ bool ED_mask_layer_select_check(const MaskLayer *mask_layer)
return false;
}
- for (const MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (const MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
return true;
}
@@ -85,8 +85,7 @@ bool ED_mask_layer_select_check(const MaskLayer *mask_layer)
bool ED_mask_select_check(const Mask *mask)
{
- for (const MaskLayer *mask_layer = mask->masklayers.first; mask_layer;
- mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (const MaskLayer *, mask_layer, &mask->masklayers) {
if (ED_mask_layer_select_check(mask_layer)) {
return true;
}
@@ -122,7 +121,7 @@ void ED_mask_layer_select_set(MaskLayer *mask_layer, const bool do_select)
}
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
ED_mask_spline_select_set(spline, do_select);
}
}
@@ -138,7 +137,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
}
}
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & MASK_RESTRICT_VIEW) {
continue;
@@ -151,7 +150,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
if (mask_layer->restrictflag & MASK_RESTRICT_SELECT) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
int i;
for (i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -167,8 +166,8 @@ void ED_mask_select_toggle_all(Mask *mask, int action)
void ED_mask_select_flush_all(Mask *mask)
{
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
spline->flag &= ~SELECT;
/* intentionally _dont_ do this in the mask layer loop
@@ -459,12 +458,12 @@ static int box_select_exec(bContext *C, wmOperator *op)
ED_mask_point_pos(area, region, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (int i = 0; i < spline->tot_point; i++) {
@@ -544,12 +543,12 @@ static bool do_lasso_select_mask(bContext *C,
BLI_lasso_boundbox(&rect, mcords, moves);
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (int i = 0; i < spline->tot_point; i++) {
@@ -686,12 +685,12 @@ static int circle_select_exec(bContext *C, wmOperator *op)
}
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline);
for (i = 0; i < spline->tot_point; i++) {
@@ -815,12 +814,12 @@ static int mask_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
bool changed = false;
/* do actual selection */
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
if (ED_mask_spline_select_check(spline)) {
ED_mask_spline_select_set(spline, true);
changed = true;
@@ -865,12 +864,12 @@ static int mask_select_more_less(bContext *C, bool more)
{
Mask *mask = CTX_data_edit_mask(C);
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0;
bool start_sel, end_sel, prev_sel, cur_sel;
int i;
diff --git a/source/blender/editors/mask/mask_shapekey.c b/source/blender/editors/mask/mask_shapekey.c
index 25b602d63c3..f264e67d35c 100644
--- a/source/blender/editors/mask/mask_shapekey.c
+++ b/source/blender/editors/mask/mask_shapekey.c
@@ -53,7 +53,7 @@ static int mask_shape_key_insert_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
MaskLayerShape *mask_layer_shape;
if (!ED_mask_layer_select_check(mask_layer)) {
@@ -98,7 +98,7 @@ static int mask_shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op))
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
MaskLayerShape *mask_layer_shape;
if (!ED_mask_layer_select_check(mask_layer)) {
@@ -146,7 +146,7 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)
Mask *mask = CTX_data_edit_mask(C);
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
@@ -172,7 +172,7 @@ static int mask_shape_key_feather_reset_exec(bContext *C, wmOperator *UNUSED(op)
shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_reset->data;
shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape->data;
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -243,7 +243,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
const bool do_feather = RNA_boolean_get(op->ptr, "feather");
const bool do_location = RNA_boolean_get(op->ptr, "location");
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (mask_layer->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
continue;
}
@@ -324,7 +324,7 @@ static int mask_shape_key_rekey_exec(bContext *C, wmOperator *op)
shape_ele_src = (MaskLayerShapeElem *)mask_layer_shape_tmp->data;
shape_ele_dst = (MaskLayerShapeElem *)mask_layer_shape_tmp_rekey->data;
- for (MaskSpline *spline = mask_layer->splines.first; spline; spline = spline->next) {
+ LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) {
for (int i = 0; i < spline->tot_point; i++) {
MaskSplinePoint *point = &spline->points[i];
@@ -404,7 +404,7 @@ bool ED_mask_layer_shape_auto_key_all(Mask *mask, const int frame)
{
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
ED_mask_layer_shape_auto_key(mask_layer, frame);
changed = true;
}
@@ -416,7 +416,7 @@ bool ED_mask_layer_shape_auto_key_select(Mask *mask, const int frame)
{
bool changed = false;
- for (MaskLayer *mask_layer = mask->masklayers.first; mask_layer; mask_layer = mask_layer->next) {
+ LISTBASE_FOREACH (MaskLayer *, mask_layer, &mask->masklayers) {
if (!ED_mask_layer_select_check(mask_layer)) {
continue;
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index aa737a1701a..feb6b5aaca9 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -1031,7 +1031,7 @@ static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmo
* could shift because of float precision.
* Updates in this case are also redundant. */
bool is_modal = false;
- for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
if (gz->state & WM_GIZMO_STATE_MODAL) {
is_modal = true;
break;
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index 08976cc46c4..998e0d736e6 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -370,8 +370,7 @@ void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data)
* cycles.
*/
#if 0
- for (Object *other_object = bmain->objects.first; other_object != NULL;
- other_object = other_object->id.next) {
+ for (Object *other_object = bmain->objects.first; other_object != NULL; other_object = other_object->id.next) {
if (other_object->data == ob->data) {
BKE_object_free_derived_caches(other_object);
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 519822dd65c..4a1450eaccc 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -161,7 +161,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
*/
if (key) {
/* if this mesh has any shapekeys, check first, otherwise just copy coordinates */
- for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
+ LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
/* get pointer to where to write data for this mesh in shapekey's data array */
float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs;
@@ -191,7 +191,7 @@ static void join_mesh_single(Depsgraph *depsgraph,
* - otherwise, copy across plain coordinates (no need to transform coordinates)
*/
if (key) {
- for (KeyBlock *kb = key->block.first; kb; kb = kb->next) {
+ LISTBASE_FOREACH (KeyBlock *, kb, &key->block) {
/* get pointer to where to write data for this mesh in shapekey's data array */
float(*cos)[3] = ((float(*)[3])kb->data) + *vertofs;
@@ -440,7 +440,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
/* Join this object's face maps to the base one's. */
- for (bFaceMap *fmap = ob_iter->fmaps.first; fmap; fmap = fmap->next) {
+ LISTBASE_FOREACH (bFaceMap *, fmap, &ob_iter->fmaps) {
/* See if this group exists in the object (if it doesn't, add it to the end) */
if (BKE_object_facemap_find_name(ob, fmap->name) == NULL) {
bFaceMap *fmap_new = MEM_mallocN(sizeof(bFaceMap), "join faceMap");
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index b96f225f660..9386c466f95 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -456,7 +456,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op)
RNG *rng = BLI_rng_new_srandom(seed_iter);
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (BLI_rng_get_float(rng) < randfac) {
if (select) {
ml->flag |= SELECT;
@@ -656,7 +656,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
bool changed = false;
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (ml->flag & MB_HIDE) {
SET_FLAG_FROM_TEST(ml->flag, select, SELECT);
ml->flag &= ~MB_HIDE;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index a74dc6a1384..9119d1cac86 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2255,7 +2255,7 @@ static int convert_exec(bContext *C, wmOperator *op)
* needed since re-evaluating single modifiers causes bugs if they depend
* on other objects data masks too, see: T50950. */
{
- for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
+ LISTBASE_FOREACH (CollectionPointerLink *, link, &selected_editable_bases) {
Base *base = link->ptr.data;
Object *ob = base->object;
@@ -2282,7 +2282,7 @@ static int convert_exec(bContext *C, wmOperator *op)
scene->customdata_mask = customdata_mask_prev;
}
- for (CollectionPointerLink *link = selected_editable_bases.first; link; link = link->next) {
+ LISTBASE_FOREACH (CollectionPointerLink *, link, &selected_editable_bases) {
Object *newob = NULL;
Base *base = link->ptr.data;
Object *ob = base->object;
diff --git a/source/blender/editors/object/object_data_transform.c b/source/blender/editors/object/object_data_transform.c
index fc91cbb9666..54fd1fe6671 100644
--- a/source/blender/editors/object/object_data_transform.c
+++ b/source/blender/editors/object/object_data_transform.c
@@ -92,7 +92,7 @@ static struct ElemData_Armature *armature_coords_and_quats_get_recurse(
const ListBase *bone_base, struct ElemData_Armature *elem_array)
{
struct ElemData_Armature *elem = elem_array;
- for (const Bone *bone = bone_base->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (const Bone *, bone, bone_base) {
#define COPY_PTR(member) memcpy(elem->member, bone->member, sizeof(bone->member))
#define COPY_VAL(member) memcpy(&elem->member, &bone->member, sizeof(bone->member))
@@ -125,7 +125,7 @@ static const struct ElemData_Armature *armature_coords_and_quats_apply_with_mat4
ListBase *bone_base, const struct ElemData_Armature *elem_array, const float mat[4][4])
{
const struct ElemData_Armature *elem = elem_array;
- for (Bone *bone = bone_base->first; bone; bone = bone->next) {
+ LISTBASE_FOREACH (Bone *, bone, bone_base) {
#define COPY_PTR(member) memcpy(bone->member, elem->member, sizeof(bone->member))
#define COPY_VAL(member) memcpy(&bone->member, &elem->member, sizeof(bone->member))
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index ee9b6b411ce..5506895613b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -166,7 +166,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
const bool select = RNA_boolean_get(op->ptr, "select");
bool changed = false;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->flag & BASE_HIDDEN) {
base->flag &= ~BASE_HIDDEN;
changed = true;
@@ -217,7 +217,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
bool changed = false;
/* Hide selected or unselected objects. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (!(base->flag & BASE_VISIBLE_VIEWLAYER)) {
continue;
}
@@ -321,7 +321,7 @@ void ED_collection_hide_menu_draw(const bContext *C, uiLayout *layout)
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
- for (LayerCollection *lc = lc_scene->layer_collections.first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, &lc_scene->layer_collections) {
int index = BKE_layer_collection_findindex(view_layer, lc);
uiLayout *row = uiLayoutRow(layout, false);
@@ -414,7 +414,7 @@ static bool mesh_needs_keyindex(Main *bmain, const Mesh *me)
return true;
}
if (ob->data == me) {
- for (const ModifierData *md = ob->modifiers.first; md; md = md->next) {
+ LISTBASE_FOREACH (const ModifierData *, md, &ob->modifiers) {
if (md->type == eModifierType_Hook) {
return true;
}
@@ -1593,7 +1593,7 @@ static int move_to_collection_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- for (LinkData *link = objects.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &objects) {
Object *ob = link->data;
if (!is_link) {
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index c5fccc5defd..256e32c7bfc 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1753,7 +1753,7 @@ static void libblock_relink_collection(Collection *collection, const bool do_col
BKE_libblock_relink_to_newid(&cob->ob->id);
}
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
libblock_relink_collection(child->collection, true);
}
}
@@ -1772,7 +1772,7 @@ static Collection *single_object_users_collection(Main *bmain,
}
/* We do not remap to new objects here, this is done in separate step. */
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
Object *ob = cob->ob;
/* an object may be in more than one collection */
if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) {
@@ -2106,7 +2106,7 @@ void ED_object_single_users(Main *bmain,
if (scene->nodetree) {
IDP_RelinkProperty(scene->nodetree->id.properties);
- for (bNode *node = scene->nodetree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &scene->nodetree->nodes) {
IDP_RelinkProperty(node->prop);
}
}
@@ -2245,7 +2245,7 @@ static void make_local_animdata_tag(AnimData *adt)
/* TODO: need to handle the ID-targets too? */
/* NLA Data */
- for (NlaTrack *nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
+ LISTBASE_FOREACH (NlaTrack *, nlt, &adt->nla_tracks) {
make_local_animdata_tag_strips(&nlt->strips);
}
}
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 8f01adb202e..5f9799710dc 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -246,7 +246,7 @@ Base *ED_object_find_first_by_data_id(ViewLayer *view_layer, ID *id)
Base *base_best = NULL;
int priority_best = 0;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object && base->object->data == id) {
if (base->flag & BASE_SELECTED) {
return base;
@@ -1325,7 +1325,7 @@ static bool object_select_more_less(bContext *C, const bool select)
{
ViewLayer *view_layer = CTX_data_view_layer(C);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
ob->flag &= ~OB_DONE;
ob->id.tag &= ~LIB_TAG_DOIT;
diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.c
index 8925d165b9b..00aafc2120f 100644
--- a/source/blender/editors/object/object_utils.c
+++ b/source/blender/editors/object/object_utils.c
@@ -194,7 +194,7 @@ void ED_object_xform_skip_child_container_item_ensure_from_array(
BLI_gset_add(objects_in_transdata, ob);
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (ob->parent != NULL) {
if (!BLI_gset_haskey(objects_in_transdata, ob)) {
@@ -224,7 +224,7 @@ void ED_object_xform_skip_child_container_item_ensure_from_array(
}
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (BLI_gset_haskey(objects_in_transdata, ob)) {
diff --git a/source/blender/editors/object/object_volume.c b/source/blender/editors/object/object_volume.c
index 92fb0788f6b..bb619972e80 100644
--- a/source/blender/editors/object/object_volume.c
+++ b/source/blender/editors/object/object_volume.c
@@ -96,7 +96,7 @@ static int volume_import_exec(bContext *C, wmOperator *op)
bool imported = false;
ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, false);
- for (ImageFrameRange *range = ranges.first; range; range = range->next) {
+ LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
char filename[FILE_MAX];
BLI_split_file_part(range->filepath, filename, sizeof(filename));
BLI_path_extension_replace(filename, sizeof(filename), "");
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 3d87220979b..1237c2c2eda 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -551,7 +551,7 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
for (win = wm->windows.first; win && matched_area == NULL; win = win->next) {
const 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) {
SpaceImage *sima = area->spacedata.first;
// area->spacedata might be empty when toggling fullscreen mode.
@@ -689,7 +689,7 @@ static void render_image_restore_layer(RenderJob *rj)
for (win = wm->windows.first; win; win = win->next) {
const 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 == rj->area) {
if (area->spacetype == SPACE_IMAGE) {
SpaceImage *sima = area->spacedata.first;
@@ -887,7 +887,7 @@ static void clean_viewport_memory(Main *bmain, Scene *scene)
/* Go over all the visible objects. */
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- 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);
for (base = view_layer->object_bases.first; base; base = base->next) {
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 2c508472a9c..0432057bb47 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -304,7 +304,7 @@ static void set_preview_visibility(Scene *scene,
}
/* Hide floor for icon renders. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (STREQ(base->object->id.name + 2, "Floor")) {
if (pr_method == PR_ICON_RENDER) {
base->object->restrictflag |= OB_RESTRICT_RENDER;
@@ -463,7 +463,7 @@ static Scene *preview_prepare_scene(
sce->display.render_aa = SCE_DISPLAY_AA_OFF;
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->id.name[2] == 'p') {
/* copy over object color, in case material uses it */
copy_v4_v4(base->object->color, sp->color);
@@ -522,7 +522,7 @@ static Scene *preview_prepare_scene(
sce->world->horb = 0.0f;
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->id.name[2] == 'p') {
if (base->object->type == OB_LAMP) {
base->object->data = la;
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 24b1c5a36f8..10f69f3fe9d 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -182,7 +182,7 @@ void ED_render_engine_changed(Main *bmain)
{
/* on changing the render engine type, clear all running render engines */
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
ED_render_engine_area_exit(bmain, area);
}
}
@@ -206,7 +206,7 @@ void ED_render_engine_changed(Main *bmain)
void ED_render_view_layer_changed(Main *bmain, bScreen *screen)
{
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
ED_render_engine_area_exit(bmain, area);
}
}
diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.c
index 114cb54636a..d78b1532a39 100644
--- a/source/blender/editors/scene/scene_edit.c
+++ b/source/blender/editors/scene/scene_edit.c
@@ -99,7 +99,7 @@ bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene)
return false;
}
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->parent != NULL) { /* We only care about main windows here... */
continue;
}
@@ -175,7 +175,7 @@ bool ED_scene_view_layer_delete(Main *bmain, Scene *scene, ViewLayer *layer, Rep
/* Remove from windows. */
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win->scene == scene && STREQ(win->view_layer_name, layer->name)) {
ViewLayer *first_layer = BKE_view_layer_default_view(scene);
STRNCPY(win->view_layer_name, first_layer->name);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 751f37dc5ec..49838b62b71 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -799,7 +799,7 @@ void ED_workspace_status_text(bContext *C, const char *str)
}
/* Redraw status bar. */
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
if (area->spacetype == SPACE_STATUSBAR) {
ED_area_tag_redraw(area);
break;
@@ -1824,7 +1824,7 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar
/* Dynamically sized regions may have changed region sizes, so we have to force azone update. */
area_azone_initialize(win, screen, area);
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
region_subwindow(region);
/* region size may have changed, init does necessary adjustments */
@@ -2176,7 +2176,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
if (sync_header_alignment) {
/* Spaces with footer. */
if (st->spaceid == SPACE_TEXT) {
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
region->alignment = header_alignment;
}
@@ -2189,7 +2189,7 @@ void ED_area_newspace(bContext *C, ScrArea *area, int type, const bool skip_regi
}
}
else {
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (ELEM(region->regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) {
region->alignment = header_alignment;
break;
@@ -2440,7 +2440,7 @@ static void ed_panel_draw(const bContext *C,
/* Draw child panels. */
if (open) {
- for (LinkData *link = pt->children.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &pt->children) {
PanelType *child_pt = link->data;
Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt);
@@ -2856,7 +2856,7 @@ int ED_area_headersize(void)
int ED_area_header_alignment_or_fallback(const ScrArea *area, int fallback)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_HEADER) {
return region->alignment;
}
@@ -2877,7 +2877,7 @@ int ED_area_footersize(void)
int ED_area_footer_alignment_or_fallback(const ScrArea *area, int fallback)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_FOOTER) {
return region->alignment;
}
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index 089865bb60c..2ac113d2ba7 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -130,7 +130,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "visible_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_VISIBLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -139,7 +139,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selectable_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTABLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -148,7 +148,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTED(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -157,7 +157,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_editable_objects")) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTED_EDITABLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -167,7 +167,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "editable_objects")) {
/* Visible + Editable, but not necessarily selected */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_EDITABLE(v3d, base)) {
CTX_data_id_list_add(result, &base->object->id);
}
@@ -726,7 +726,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
CTX_data_list_add(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data);
}
@@ -749,7 +749,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) {
CTX_data_pointer_set(result, ale->fcurve_owner_id, &RNA_FCurve, ale->data);
break;
diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c
index c1b6df07129..2452302561b 100644
--- a/source/blender/editors/screen/screen_draw.c
+++ b/source/blender/editors/screen/screen_draw.c
@@ -547,7 +547,7 @@ static void screen_preview_scale_get(
{
float max_x = 0, max_y = 0;
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
max_x = MAX2(max_x, area->totrct.xmax);
max_y = MAX2(max_y, area->totrct.ymax);
}
@@ -566,7 +566,7 @@ static void screen_preview_draw_areas(const bScreen *screen,
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4fv(col);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
rctf rect = {
.xmin = area->totrct.xmin * scale[0] + ofs_h,
.xmax = area->totrct.xmax * scale[0] - ofs_h,
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 16ef93872ff..8608c18c988 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -415,7 +415,7 @@ static void region_cursor_set(wmWindow *win, bool swin_changed)
ED_screen_areas_iter(win, screen, area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region == screen->active_region) {
region_cursor_set_ex(win, area, region, swin_changed);
return;
@@ -607,14 +607,14 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen)
screen->active_region = NULL;
- for (ARegion *region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
ED_region_exit(C, region);
}
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
ED_area_exit(C, area);
}
/* Don't use ED_screen_areas_iter here, it skips hidden areas. */
- for (ScrArea *area = window->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &window->global_areas.areabase) {
ED_area_exit(C, area);
}
@@ -912,7 +912,7 @@ void ED_screen_global_areas_sync(wmWindow *win)
screen->flag &= ~SCREEN_COLLAPSE_STATUSBAR;
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
if (area->global->cur_fixed_height == area->global->size_min) {
if (area->spacetype == SPACE_STATUSBAR) {
screen->flag |= SCREEN_COLLAPSE_STATUSBAR;
@@ -978,7 +978,7 @@ bScreen *screen_change_prepare(
wmTimer *wt = screen_old->animtimer;
/* remove handlers referencing areas in old screen */
- for (ScrArea *area = screen_old->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen_old->areabase) {
WM_event_remove_area_handler(&win->modalhandlers, area);
}
@@ -1109,8 +1109,8 @@ void ED_screen_scene_change(bContext *C, wmWindow *win, Scene *scene)
/* Update 3D view cameras. */
const bScreen *screen = WM_window_get_active_screen(win);
- 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;
screen_set_3dview_camera(scene, view_layer, area, v3d);
@@ -1249,7 +1249,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
/* find old area to restore from */
ScrArea *fullsa = NULL;
- for (ScrArea *old = screen->areabase.first; old; old = old->next) {
+ LISTBASE_FOREACH (ScrArea *, old, &screen->areabase) {
/* area to restore from is always first */
if (old->full && !fullsa) {
fullsa = old;
@@ -1270,8 +1270,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
if (state == SCREENFULL) {
/* unhide global areas */
- for (ScrArea *glob_area = win->global_areas.areabase.first; glob_area;
- glob_area = glob_area->next) {
+ LISTBASE_FOREACH (ScrArea *, glob_area, &win->global_areas.areabase) {
glob_area->global->flag &= ~GLOBAL_AREA_IS_HIDDEN;
}
/* restore the old side panels/header visibility */
@@ -1335,8 +1334,7 @@ ScrArea *ED_screen_state_toggle(bContext *C, wmWindow *win, ScrArea *area, const
if (state == SCREENFULL) {
/* temporarily hide global areas */
- for (ScrArea *glob_area = win->global_areas.areabase.first; glob_area;
- glob_area = glob_area->next) {
+ LISTBASE_FOREACH (ScrArea *, glob_area, &win->global_areas.areabase) {
glob_area->global->flag |= GLOBAL_AREA_IS_HIDDEN;
}
/* temporarily hide the side panels/header */
@@ -1662,7 +1660,7 @@ Scene *ED_screen_scene_find_with_window(const bScreen *screen,
const wmWindowManager *wm,
struct wmWindow **r_window)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (WM_window_get_active_screen(win) == screen) {
if (r_window) {
*r_window = win;
@@ -1680,14 +1678,14 @@ ScrArea *ED_screen_area_find_with_spacedata(const bScreen *screen,
const bool only_visible)
{
if (only_visible) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacedata.first == sl) {
return area;
}
}
}
else {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (BLI_findindex(&area->spacedata, sl) != -1) {
return area;
}
@@ -1703,7 +1701,7 @@ Scene *ED_screen_scene_find(const bScreen *screen, const wmWindowManager *wm)
wmWindow *ED_screen_window_find(const bScreen *screen, const wmWindowManager *wm)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (WM_window_get_active_screen(win) == screen) {
return win;
}
diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c
index 178c375c8ee..4069795657e 100644
--- a/source/blender/editors/screen/screen_geometry.c
+++ b/source/blender/editors/screen/screen_geometry.c
@@ -96,7 +96,7 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map,
CLAMP_MIN(safety, 2);
- for (ScrEdge *se = area_map->edgebase.first; se; se = se->next) {
+ LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) {
if (screen_geom_edge_is_horizontal(se)) {
if ((se->v1->vec.y > bounds_rect->ymin) && (se->v1->vec.y < (bounds_rect->ymax - 1))) {
short min, max;
@@ -198,7 +198,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
if (facy > 1) {
/* Keep timeline small in video edit workspace. */
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacetype == SPACE_ACTION && area->v1->vec.y == screen_rect.ymin &&
screen_geom_area_height(area) <= headery * facy + 1) {
ScrEdge *se = BKE_screen_find_edge(screen, area->v2, area->v3);
@@ -222,7 +222,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
}
if (facy < 1) {
/* make each window at least ED_area_headersize() high */
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (screen_geom_area_height(area) < headery) {
/* lower edge */
ScrEdge *se = BKE_screen_find_edge(screen, area->v4, area->v1);
@@ -248,7 +248,7 @@ void screen_geom_vertices_scale(const wmWindow *win, bScreen *screen)
/* Global areas have a fixed size that only changes with the DPI.
* Here we ensure that exactly this size is set. */
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
if (area->global->flag & GLOBAL_AREA_IS_HIDDEN) {
continue;
}
@@ -379,7 +379,7 @@ void screen_geom_select_connected_edge(const wmWindow *win, ScrEdge *edge)
while (oneselected) {
oneselected = false;
- for (ScrEdge *se = screen->edgebase.first; se; se = se->next) {
+ LISTBASE_FOREACH (ScrEdge *, se, &screen->edgebase) {
if (se->v1->flag + se->v2->flag == 1) {
if (dir == 'h') {
if (se->v1->vec.y == se->v2->vec.y) {
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 08bf6f67215..452984f2333 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -681,7 +681,7 @@ static bool actionzone_area_poll(bContext *C)
const int *xy = &win->eventstate->x;
AZone *az;
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
for (az = area->actionzones.first; az; az = az->next) {
if (BLI_rcti_isect_pt_v(&az->rect, xy)) {
return 1;
@@ -895,7 +895,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *area, const int xy[2], const b
/* Finds an action-zone by position in entire screen so azones can overlap. */
static AZone *screen_actionzone_find_xy(bScreen *screen, const int xy[2])
{
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
AZone *az = area_actionzone_refresh_xy(area, xy, true);
if (az != NULL) {
return az;
@@ -907,8 +907,8 @@ static AZone *screen_actionzone_find_xy(bScreen *screen, const int xy[2])
/* Returns the area that the azone belongs to */
static ScrArea *screen_actionzone_area(bScreen *screen, const AZone *az)
{
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (AZone *zone = area->actionzones.first; zone; zone = zone->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (AZone *, zone, &area->actionzones) {
if (zone == az) {
return area;
}
@@ -1470,7 +1470,7 @@ static void area_move_set_limits(wmWindow *win,
if (use_bigger_smaller_snap != NULL) {
*use_bigger_smaller_snap = false;
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
int size_min = ED_area_global_min_size_y(area) - 1;
int size_max = ED_area_global_max_size_y(area) - 1;
@@ -1511,7 +1511,7 @@ static void area_move_set_limits(wmWindow *win,
WM_window_rect_calc(win, &window_rect);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (dir == 'h') {
int y1;
areamin = areaminy;
@@ -1661,13 +1661,13 @@ static int area_snap_calc_location(const bScreen *screen,
}
}
- for (const ScrVert *v1 = screen->vertbase.first; v1; v1 = v1->next) {
+ LISTBASE_FOREACH (const ScrVert *, v1, &screen->vertbase) {
if (!v1->editflag) {
continue;
}
const int v_loc = (&v1->vec.x)[!axis];
- for (const ScrVert *v2 = screen->vertbase.first; v2; v2 = v2->next) {
+ LISTBASE_FOREACH (const ScrVert *, v2, &screen->vertbase) {
if (v2->editflag) {
continue;
}
@@ -2504,7 +2504,7 @@ static int area_max_regionsize(ScrArea *area, ARegion *scalear, AZEdge edge)
/* subtractwidth of regions on opposite side
* prevents dragging regions into other opposite regions */
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region == scalear) {
continue;
}
@@ -2801,11 +2801,11 @@ static void areas_do_frame_follow(bContext *C, bool middle)
bScreen *screen_ctx = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
- for (wmWindow *window = wm->windows.first; window; window = window->next) {
+ LISTBASE_FOREACH (wmWindow *, window, &wm->windows) {
const bScreen *screen = WM_window_get_active_screen(window);
- 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) {
/* do follow here if editor type supports it */
if ((screen_ctx->redraws_flag & TIME_FOLLOW)) {
if ((region->regiontype == RGN_TYPE_WINDOW &&
@@ -4595,7 +4595,7 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot)
/* find window that owns the animation timer */
bScreen *ED_screen_animation_playing(const wmWindowManager *wm)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
if (screen->animtimer || screen->scrubbing) {
@@ -4608,7 +4608,7 @@ bScreen *ED_screen_animation_playing(const wmWindowManager *wm)
bScreen *ED_screen_animation_no_scrub(const wmWindowManager *wm)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
bScreen *screen = WM_window_get_active_screen(win);
if (screen->animtimer) {
@@ -5388,7 +5388,7 @@ static int space_workspace_cycle_invoke(bContext *C, wmOperator *op, const wmEve
ListBase ordered;
BKE_id_ordered_list(&ordered, &bmain->workspaces);
- for (LinkData *link = ordered.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &ordered) {
if (link->data == workspace_src) {
if (direction == SPACE_CONTEXT_CYCLE_PREV) {
workspace_dst = (link->prev) ? link->prev->data : NULL;
diff --git a/source/blender/editors/screen/screen_user_menu.c b/source/blender/editors/screen/screen_user_menu.c
index 38d83801f2b..733e8b694a6 100644
--- a/source/blender/editors/screen/screen_user_menu.c
+++ b/source/blender/editors/screen/screen_user_menu.c
@@ -113,7 +113,7 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb,
IDProperty *prop,
short opcontext)
{
- for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, lb) {
if (umi->type == USER_MENU_TYPE_OPERATOR) {
bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
if (STREQ(ot->idname, umi_op->op_idname) && (opcontext == umi_op->opcontext) &&
@@ -128,7 +128,7 @@ bUserMenuItem_Op *ED_screen_user_menu_item_find_operator(ListBase *lb,
struct bUserMenuItem_Menu *ED_screen_user_menu_item_find_menu(struct ListBase *lb,
const struct MenuType *mt)
{
- for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, lb) {
if (umi->type == USER_MENU_TYPE_MENU) {
bUserMenuItem_Menu *umi_mt = (bUserMenuItem_Menu *)umi;
if (STREQ(mt->idname, umi_mt->mt_idname)) {
@@ -144,7 +144,7 @@ struct bUserMenuItem_Prop *ED_screen_user_menu_item_find_prop(struct ListBase *l
const char *prop_id,
int prop_index)
{
- for (bUserMenuItem *umi = lb->first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, lb) {
if (umi->type == USER_MENU_TYPE_PROP) {
bUserMenuItem_Prop *umi_pr = (bUserMenuItem_Prop *)umi;
if (STREQ(context_data_path, umi_pr->context_data_path) && STREQ(prop_id, umi_pr->prop_id) &&
@@ -222,7 +222,7 @@ static void screen_user_menu_draw(const bContext *C, Menu *menu)
if (um == NULL) {
continue;
}
- for (bUserMenuItem *umi = um->items.first; umi; umi = umi->next) {
+ LISTBASE_FOREACH (bUserMenuItem *, umi, &um->items) {
const char *ui_name = umi->ui_name[0] ? umi->ui_name : NULL;
if (umi->type == USER_MENU_TYPE_OPERATOR) {
bUserMenuItem_Op *umi_op = (bUserMenuItem_Op *)umi;
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];
diff --git a/source/blender/editors/screen/workspace_layout_edit.c b/source/blender/editors/screen/workspace_layout_edit.c
index 1e85a6e256f..cf9637788a9 100644
--- a/source/blender/editors/screen/workspace_layout_edit.c
+++ b/source/blender/editors/screen/workspace_layout_edit.c
@@ -68,7 +68,7 @@ WorkSpaceLayout *ED_workspace_layout_duplicate(Main *bmain,
screen_new = BKE_workspace_layout_screen_get(layout_new);
if (BKE_screen_is_fullscreen_area(screen_old)) {
- for (ScrArea *area_old = screen_old->areabase.first; area_old; area_old = area_old->next) {
+ LISTBASE_FOREACH (ScrArea *, area_old, &screen_old->areabase) {
if (area_old->full) {
ScrArea *area_new = (ScrArea *)screen_new->areabase.first;
ED_area_data_copy(area_new, area_old, true);
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);
}
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 605d239133a..52287b07b28 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -561,7 +561,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
/* Iterate over pointcaches on the active object, and draw each one's range. */
float y_offset = 0.0f;
const float cache_draw_height = 4.0f * UI_DPI_FAC * U.pixelsize;
- for (PTCacheID *pid = pidlist.first; pid; pid = pid->next) {
+ LISTBASE_FOREACH (PTCacheID *, pid, &pidlist) {
if (timeline_cache_is_hidden_by_setting(saction, pid)) {
continue;
}
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 173c2f1b5dc..26c29d6cbe7 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -437,7 +437,7 @@ static void box_select_elem(
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype);
- for (bAnimListElem *ale2 = anim_data.first; ale2; ale2 = ale2->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
box_select_elem(sel_data, ale2, xmin, xmax, true);
}
@@ -675,7 +675,7 @@ static void region_select_elem(RegionSelectData *sel_data, bAnimListElem *ale, b
ListBase anim_data = {NULL, NULL};
ANIM_animdata_filter(ac, &anim_data, ANIMFILTER_DATA_VISIBLE, ac->data, ac->datatype);
- for (bAnimListElem *ale2 = anim_data.first; ale2; ale2 = ale2->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale2, &anim_data) {
region_select_elem(sel_data, ale2, true);
}
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index f3304a48cac..e92ea906237 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -563,7 +563,7 @@ static void action_listener(wmWindow *UNUSED(win),
ED_area_tag_redraw(area);
break;
case ND_FRAME_RANGE:
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
Scene *scene = wmn->reference;
region->v2d.tot.xmin = (float)(SFRA - 4);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index c8488fc13a4..c06c107d4a3 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -312,7 +312,7 @@ static void buttons_navigation_bar_region_init(wmWindowManager *wm, ARegion *reg
static void buttons_navigation_bar_region_draw(const bContext *C, ARegion *region)
{
- for (PanelType *pt = region->type->paneltypes.first; pt; pt = pt->next) {
+ LISTBASE_FOREACH (PanelType *, pt, &region->type->paneltypes) {
pt->flag |= PNL_LAYOUT_VERT_BAR;
}
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 0453e58d3fb..ffc50407917 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -311,10 +311,10 @@ void ED_clip_update_frame(const Main *mainp, int cfra)
{
/* image window, compo node users */
for (wmWindowManager *wm = mainp->wm.first; wm; wm = wm->id.next) { /* only 1 wm */
- 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_CLIP) {
SpaceClip *sc = area->spacedata.first;
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 38f67623c99..67e64c52051 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1275,7 +1275,7 @@ static Image *image_open_single(Main *bmain,
if ((range->length > 1) && (ima->source == IMA_SRC_FILE)) {
if (range->udim_tiles.first && range->offset == 1001) {
ima->source = IMA_SRC_TILED;
- for (LinkData *node = range->udim_tiles.first; node; node = node->next) {
+ LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
BKE_image_add_tile(ima, POINTER_AS_INT(node->data), NULL);
}
}
@@ -1309,7 +1309,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
}
ListBase ranges = ED_image_filesel_detect_sequences(bmain, op, use_udim);
- for (ImageFrameRange *range = ranges.first; range; range = range->next) {
+ LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
Image *ima_range = image_open_single(
bmain, op, range, BKE_main_blendfile_path(bmain), is_relative_path, use_multiview);
@@ -1359,7 +1359,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
if (iuser == NULL) {
Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
if (cam) {
- for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) {
+ LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
if (bgpic->ima == ima) {
iuser = &bgpic->iuser;
break;
diff --git a/source/blender/editors/space_image/image_sequence.c b/source/blender/editors/space_image/image_sequence.c
index 245495bd179..8b298045597 100644
--- a/source/blender/editors/space_image/image_sequence.c
+++ b/source/blender/editors/space_image/image_sequence.c
@@ -226,7 +226,7 @@ ListBase ED_image_filesel_detect_sequences(Main *bmain, wmOperator *op, const bo
const bool was_relative = BLI_path_is_rel(filepath);
image_sequence_get_frame_ranges(op, &ranges);
- for (ImageFrameRange *range = ranges.first; range; range = range->next) {
+ LISTBASE_FOREACH (ImageFrameRange *, range, &ranges) {
image_detect_frame_range(range, detect_udim);
BLI_freelistN(&range->frames);
diff --git a/source/blender/editors/space_image/image_undo.c b/source/blender/editors/space_image/image_undo.c
index 5f81c19290b..056dd826238 100644
--- a/source/blender/editors/space_image/image_undo.c
+++ b/source/blender/editors/space_image/image_undo.c
@@ -145,7 +145,7 @@ static void ptile_free_list(ListBase *paint_tiles)
static void ptile_invalidate_list(ListBase *paint_tiles)
{
- for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
+ LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) {
ptile->valid = false;
}
}
@@ -159,7 +159,7 @@ void *ED_image_paint_tile_find(ListBase *paint_tiles,
ushort **r_mask,
bool validate)
{
- for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
+ LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) {
if (ptile->x_tile == x_tile && ptile->y_tile == y_tile) {
if (ptile->image == image && ptile->ibuf == ibuf && ptile->iuser.tile == iuser->tile) {
if (r_mask) {
@@ -267,7 +267,7 @@ static void ptile_restore_runtime_list(ListBase *paint_tiles)
{
ImBuf *tmpibuf = imbuf_alloc_temp_tile();
- for (PaintTile *ptile = paint_tiles->first; ptile; ptile = ptile->next) {
+ LISTBASE_FOREACH (PaintTile *, ptile, paint_tiles) {
Image *image = ptile->image;
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &ptile->iuser, NULL);
const bool has_float = (ibuf->rect_float != NULL);
@@ -542,7 +542,7 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init)
{
ImBuf *tmpibuf = imbuf_alloc_temp_tile();
- for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) {
/* Tiles only added to second set of tiles. */
Image *image = uh->image_ref.ptr;
@@ -552,7 +552,7 @@ static void uhandle_restore_list(ListBase *undo_handles, bool use_init)
continue;
}
bool changed = false;
- for (UndoImageBuf *ubuf_iter = uh->buffers.first; ubuf_iter; ubuf_iter = ubuf_iter->next) {
+ LISTBASE_FOREACH (UndoImageBuf *, ubuf_iter, &uh->buffers) {
UndoImageBuf *ubuf = use_init ? ubuf_iter : ubuf_iter->post;
ubuf_ensure_compat_ibuf(ubuf, ibuf);
@@ -611,7 +611,7 @@ static UndoImageBuf *uhandle_lookup_ubuf(UndoImageHandle *uh,
const Image *UNUSED(image),
const char *ibuf_name)
{
- for (UndoImageBuf *ubuf = uh->buffers.first; ubuf; ubuf = ubuf->next) {
+ LISTBASE_FOREACH (UndoImageBuf *, ubuf, &uh->buffers) {
if (STREQ(ubuf->ibuf_name, ibuf_name)) {
return ubuf;
}
@@ -643,7 +643,7 @@ static UndoImageHandle *uhandle_lookup_by_name(ListBase *undo_handles,
const Image *image,
int tile_number)
{
- for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) {
if (STREQ(image->id.name + 2, uh->image_ref.name + 2) && uh->iuser.tile == tile_number) {
return uh;
}
@@ -653,7 +653,7 @@ static UndoImageHandle *uhandle_lookup_by_name(ListBase *undo_handles,
static UndoImageHandle *uhandle_lookup(ListBase *undo_handles, const Image *image, int tile_number)
{
- for (UndoImageHandle *uh = undo_handles->first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, undo_handles) {
if (image == uh->image_ref.ptr && uh->iuser.tile == tile_number) {
return uh;
}
@@ -799,8 +799,8 @@ static bool image_undosys_step_encode(struct bContext *C,
}
BLI_listbase_clear(&us->paint_tiles);
- for (UndoImageHandle *uh = us->handles.first; uh; uh = uh->next) {
- for (UndoImageBuf *ubuf_pre = uh->buffers.first; ubuf_pre; ubuf_pre = ubuf_pre->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, &us->handles) {
+ LISTBASE_FOREACH (UndoImageBuf *, ubuf_pre, &uh->buffers) {
ImBuf *ibuf = BKE_image_acquire_ibuf(uh->image_ref.ptr, &uh->iuser, NULL);
@@ -979,7 +979,7 @@ static void image_undosys_foreach_ID_ref(UndoStep *us_p,
void *user_data)
{
ImageUndoStep *us = (ImageUndoStep *)us_p;
- for (UndoImageHandle *uh = us->handles.first; uh; uh = uh->next) {
+ LISTBASE_FOREACH (UndoImageHandle *, uh, &us->handles) {
foreach_ID_ref_fn(user_data, ((UndoRefID *)&uh->image_ref));
}
}
diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c
index 7499c057950..adc6391a0f6 100644
--- a/source/blender/editors/space_info/info_report.c
+++ b/source/blender/editors/space_info/info_report.c
@@ -250,7 +250,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode");
const int select = (sel_op != SEL_OP_SUB);
if (SEL_OP_USE_PRE_DESELECT(sel_op)) {
- for (Report *report = reports->list.first; report; report = report->next) {
+ LISTBASE_FOREACH (Report *, report, &reports->list) {
if ((report->type & report_mask) == 0) {
continue;
}
@@ -264,7 +264,7 @@ static int box_select_exec(bContext *C, wmOperator *op)
/* get the first report if none found */
if (report_min == NULL) {
// printf("find_min\n");
- for (Report *report = reports->list.first; report; report = report->next) {
+ LISTBASE_FOREACH (Report *, report, &reports->list) {
if (report->type & report_mask) {
report_min = report;
break;
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index d08d39700d6..5adcec8a5d7 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -146,7 +146,7 @@ static int mouse_nla_channels(
else {
/* deselect all */
/* TODO: should this deselect all other types of channels too? */
- for (Base *b = view_layer->object_bases.first; b; b = b->next) {
+ LISTBASE_FOREACH (Base *, b, &view_layer->object_bases) {
ED_object_base_select(b, BA_DESELECT);
if (b->object->adt) {
b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE);
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 5a59ba6b553..5c4ccd96534 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -150,7 +150,7 @@ static void nla_action_draw_keyframes(
/* - disregard the selection status of keyframes so they draw a certain way
* - size is 6.0f which is smaller than the editable keyframes, so that there is a distinction
*/
- for (ActKeyColumn *ak = keys.first; ak; ak = ak->next) {
+ LISTBASE_FOREACH (ActKeyColumn *, ak, &keys) {
draw_keyframe_shape(ak->cfra,
y,
6.0f,
@@ -207,7 +207,7 @@ static void nla_actionclip_draw_markers(
immUniformThemeColorShade(TH_STRIP_SELECT, shade);
immBeginAtMost(GPU_PRIM_LINES, BLI_listbase_count(&act->markers) * 2);
- for (TimeMarker *marker = act->markers.first; marker; marker = marker->next) {
+ LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) {
float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP);
@@ -238,7 +238,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc)
/* just a solid color, so that it is very easy to spot */
int shade = 20;
/* draw the markers in the first level of strips only (if they are actions) */
- for (NlaStrip *nls = strip->strips.first; nls; nls = nls->next) {
+ LISTBASE_FOREACH (NlaStrip *, nls, &strip->strips) {
if (nls->type == NLASTRIP_TYPE_CLIP) {
nla_actionclip_draw_markers(nls, yminc, ymaxc, shade, false);
}
@@ -565,7 +565,7 @@ static void nla_draw_strip(SpaceNla *snla,
immBeginAtMost(GPU_PRIM_LINES, 4 * BLI_listbase_count(&strip->strips));
/* only draw first-level of child-strips, but don't draw any lines on the endpoints */
- for (NlaStrip *cs = strip->strips.first; cs; cs = cs->next) {
+ LISTBASE_FOREACH (NlaStrip *, cs, &strip->strips) {
/* draw start-line if not same as end of previous (and only if not the first strip)
* - on upper half of strip
*/
diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c
index 09abfc300c7..ec41368b9f0 100644
--- a/source/blender/editors/space_nla/nla_select.c
+++ b/source/blender/editors/space_nla/nla_select.c
@@ -308,7 +308,7 @@ static void nlaedit_strip_at_region_position(
if (ale->type == ANIMTYPE_NLATRACK) {
NlaTrack *nlt = (NlaTrack *)ale->data;
- for (NlaStrip *strip = nlt->strips.first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
*r_ale = ale;
*r_strip = strip;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index c231314ba59..a82acfc4dbe 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -1326,7 +1326,7 @@ void NODE_OT_duplicate(wmOperatorType *ot)
bool ED_node_select_check(ListBase *lb)
{
- for (bNode *node = lb->first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, lb) {
if (node->flag & NODE_SELECT) {
return true;
}
@@ -1346,7 +1346,7 @@ void ED_node_select_all(ListBase *lb, int action)
}
}
- for (bNode *node = lb->first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, lb) {
switch (action) {
case SEL_SELECT:
nodeSetSelected(node, true);
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 03a99a74614..8f8f945a600 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -466,7 +466,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
if (tonode) {
/* Find a selected socket that overrides the socket to connect to */
- for (bNodeSocket *sock2 = tonode->outputs.first; sock2; sock2 = sock2->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock2, &tonode->outputs) {
if (!nodeSocketIsHidden(sock2) && sock2->flag & SELECT) {
sock = sock2;
break;
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 43daedfa1c2..38ec855e845 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -623,7 +623,7 @@ static int node_box_select_exec(bContext *C, wmOperator *op)
ED_node_select_all(&snode->edittree->nodes, SEL_DESELECT);
}
- for (bNode *node = snode->edittree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &snode->edittree->nodes) {
bool is_inside;
if (node->type == NODE_FRAME) {
is_inside = BLI_rctf_inside_rctf(&rectf, &node->totr);
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 8563b7d8c24..5a0ed954909 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -336,8 +336,7 @@ static int collection_delete_exec(bContext *C, wmOperator *op)
skip = true;
}
else {
- for (CollectionParent *cparent = collection->parents.first; cparent;
- cparent = cparent->next) {
+ LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
Collection *parent = cparent->collection;
if (ID_IS_LINKED(parent)) {
skip = true;
@@ -848,7 +847,7 @@ static bool collections_indirect_only_clear_poll(bContext *C)
static void layer_collection_flag_recursive_set(LayerCollection *lc, int flag)
{
- for (LayerCollection *nlc = lc->layer_collections.first; nlc; nlc = nlc->next) {
+ LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) {
if (lc->flag & flag) {
nlc->flag |= flag;
}
@@ -1468,14 +1467,13 @@ static int outliner_unhide_all_exec(bContext *C, wmOperator *UNUSED(op))
/* Unhide all the collections. */
LayerCollection *lc_master = view_layer->layer_collections.first;
- for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) {
lc_iter->flag &= ~LAYER_COLLECTION_HIDE;
layer_collection_flag_recursive_set(lc_iter, LAYER_COLLECTION_HIDE);
}
/* Unhide all objects. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->flag &= ~BASE_HIDDEN;
}
diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c
index 6f071ca128e..b6f5ac25c3c 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.c
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.c
@@ -263,8 +263,7 @@ static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
* element for object it means that all displayed objects belong to
* active scene and parenting them is allowed (sergey) */
if (scene) {
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
if (BKE_view_layer_base_find(view_layer, potential_child)) {
return true;
}
@@ -481,7 +480,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven
ListBase *lb = event->customdata;
wmDrag *drag = lb->first;
- for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) {
+ LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
if (GS(drag_id->id->name) == ID_OB) {
Object *object = (Object *)drag_id->id;
@@ -548,8 +547,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent
BKE_collection_object_add(bmain, collection, ob);
- for (ViewLayer *view_layer = scene->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
Base *base = BKE_view_layer_base_find(view_layer, ob);
if (base) {
ED_object_base_select(base, BA_SELECT);
@@ -817,7 +815,7 @@ static int collection_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
TREESTORE(data.te)->flag &= ~TSE_CLOSED;
}
- for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) {
+ LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
/* Ctrl enables linking, so we don't need a from collection then. */
Collection *from = (event->ctrl) ? NULL : collection_parent_from_ID(drag_id->from_parent);
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 3c569a71e93..ce83cfc3c97 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -91,7 +91,7 @@ static void outliner_tree_dimensions_impl(SpaceOutliner *soops,
int *width,
int *height)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
*width = MAX2(*width, te->xend);
if (height != NULL) {
*height += UI_UNIT_Y;
@@ -387,8 +387,7 @@ static void outliner_collection_set_flag_recursive(Scene *scene,
if (base_or_object_prop) {
/* Note: We can't use BKE_collection_object_cache_get()
* otherwise we would not take collection exclusion into account. */
- for (CollectionObject *cob = layer_collection->collection->gobject.first; cob;
- cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &layer_collection->collection->gobject) {
outliner_base_or_object_pointer_create(view_layer, collection, cob->ob, &ptr);
RNA_property_boolean_set(&ptr, base_or_object_prop, value);
@@ -401,7 +400,7 @@ static void outliner_collection_set_flag_recursive(Scene *scene,
/* Keep going recursively. */
ListBase *lb = (layer_collection ? &layer_collection->layer_collections : &collection->children);
- for (Link *link = lb->first; link; link = link->next) {
+ LISTBASE_FOREACH (Link *, link, lb) {
LayerCollection *layer_collection_iter = layer_collection ? (LayerCollection *)link : NULL;
Collection *collection_iter = layer_collection ?
(collection ? layer_collection_iter->collection : NULL) :
@@ -467,7 +466,7 @@ static bool outliner_collection_is_isolated(Scene *scene,
/* Keep going recursively. */
ListBase *lb = (layer_collection ? &layer_collection->layer_collections : &collection->children);
- for (Link *link = lb->first; link; link = link->next) {
+ LISTBASE_FOREACH (Link *, link, lb) {
LayerCollection *layer_collection_iter = layer_collection ? (LayerCollection *)link : NULL;
Collection *collection_iter = layer_collection ?
(collection ? layer_collection_iter->collection : NULL) :
@@ -542,8 +541,7 @@ void outliner_collection_isolate_flag(Scene *scene,
/* Make this collection direct parents also "visible". */
if (layer_collection) {
LayerCollection *lc_parent = layer_collection;
- for (LayerCollection *lc_iter = top_layer_collection->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &top_layer_collection->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, layer_collection)) {
lc_parent = lc_iter;
break;
@@ -555,8 +553,7 @@ void outliner_collection_isolate_flag(Scene *scene,
scene, lc_parent, collection ? lc_parent->collection : NULL, &ptr);
RNA_property_boolean_set(&ptr, layer_or_collection_prop, !is_hide);
- for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter;
- lc_iter = lc_iter->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_parent->layer_collections) {
if (BKE_layer_collection_has_layer_collection(lc_iter, layer_collection)) {
lc_parent = lc_iter;
break;
@@ -1054,7 +1051,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
/* Create buttons. */
uiBut *bt;
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
RestrictPropertiesActive props_active = props_active_parent;
@@ -1651,7 +1648,7 @@ static void outliner_draw_userbuts(uiBlock *block,
ListBase *lb)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
if (tselem->type == 0) {
@@ -1770,7 +1767,7 @@ static void outliner_draw_rnabuts(
PointerRNA *ptr;
PropertyRNA *prop;
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
if (tselem->type == TSE_RNA_PROPERTY) {
@@ -2861,7 +2858,7 @@ static void outliner_draw_iconrow(bContext *C,
{
eOLDrawState active = OL_DRAWSEL_NONE;
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
/* object hierarchy always, further constrained on level */
@@ -3204,7 +3201,7 @@ static void outliner_draw_tree_element(bContext *C,
if (TSELEM_OPEN(tselem, soops)) {
*starty -= UI_UNIT_Y;
- for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) {
+ LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
/* check if element needs to be drawn grayed out, but also gray out
* childs of a grayed out parent (pass on draw_grayed_out to childs) */
bool draw_childs_grayed_out = draw_grayed_out || (ten->flag & TE_DRAGGING);
@@ -3223,7 +3220,7 @@ static void outliner_draw_tree_element(bContext *C,
}
}
else {
- for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) {
+ LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
outliner_set_coord_tree_element(ten, startx, *starty);
}
@@ -3357,7 +3354,7 @@ static void outliner_draw_struct_marks(ARegion *region,
ListBase *lb,
int *starty)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
/* selection status */
@@ -3406,7 +3403,7 @@ static void outliner_draw_highlights_recursive(uint pos,
const bool is_searching = (SEARCHING_OUTLINER(soops) ||
(soops->outlinevis == SO_DATA_API && soops->search_string[0] != 0));
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
const TreeStoreElem *tselem = TREESTORE(te);
const int start_y = *io_start_y;
@@ -3555,7 +3552,7 @@ static void outliner_draw_tree(bContext *C,
// items themselves
starty = (int)region->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET;
startx = 0;
- for (TreeElement *te = soops->tree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &soops->tree) {
outliner_draw_tree_element(C,
block,
fstyle,
diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c
index e4e8e2a1542..60e6b423720 100644
--- a/source/blender/editors/space_outliner/outliner_edit.c
+++ b/source/blender/editors/space_outliner/outliner_edit.c
@@ -1292,7 +1292,7 @@ static void outliner_show_active(SpaceOutliner *so, ARegion *region, TreeElement
return;
}
- for (TreeElement *ten = te->subtree.first; ten; ten = ten->next) {
+ LISTBASE_FOREACH (TreeElement *, ten, &te->subtree) {
outliner_show_active(so, region, ten, id);
}
}
@@ -1310,7 +1310,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op))
ID *id = TREESTORE(active_element)->id;
/* Expand all elements in the outliner with matching ID */
- for (TreeElement *te = so->tree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &so->tree) {
outliner_show_active(so, region, te, id);
}
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index d50a097e6f6..ec1595eb930 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -1252,7 +1252,7 @@ static bool do_outliner_range_select_recursive(ListBase *lb,
TreeElement *cursor,
bool selecting)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (selecting) {
@@ -1496,7 +1496,7 @@ static int outliner_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(&region->v2d, &rectf, &rectf);
- for (TreeElement *te = soops->tree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &soops->tree) {
outliner_item_box_select(soops, scene, &rectf, te, select);
}
diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c
index c08c7f54405..35dd91ff061 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -96,8 +96,8 @@ void ED_outliner_select_sync_flag_outliners(const bContext *C)
wmWindowManager *wm = CTX_wm_manager(C);
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_OUTLINER) {
SpaceOutliner *soutliner = (SpaceOutliner *)sl;
@@ -319,7 +319,7 @@ static void outliner_sync_selection_from_outliner(Scene *scene,
SelectedItems *selected_items)
{
- for (TreeElement *te = tree->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == 0 && te->idcode == ID_OB) {
@@ -500,7 +500,7 @@ static void outliner_sync_selection_to_outliner(ViewLayer *view_layer,
SyncSelectActiveData *active_data,
const SyncSelectTypes *sync_types)
{
- for (TreeElement *te = tree->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == 0 && te->idcode == ID_OB) {
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 730d0019f77..34ca2267b7a 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -518,7 +518,7 @@ static void merged_element_search_cb_recursive(
char name[64];
int iconid;
- for (TreeElement *te = tree->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, tree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tree_element_id_type_to_index(te) == type && tselem_type == tselem->type) {
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index d89a755f1c6..b226d291188 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1254,7 +1254,7 @@ static bool outliner_library_id_show(Library *lib, ID *id, short filter_id_type)
Collection *collection = (Collection *)id;
bool has_non_scene_parent = false;
- for (CollectionParent *cparent = collection->parents.first; cparent; cparent = cparent->next) {
+ LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) {
if (!(cparent->collection->flag & COLLECTION_IS_MASTER)) {
has_non_scene_parent = true;
}
@@ -1387,7 +1387,7 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops
static void outliner_add_layer_collection_objects(
SpaceOutliner *soops, ListBase *tree, ViewLayer *layer, LayerCollection *lc, TreeElement *ten)
{
- for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &lc->collection->gobject) {
Base *base = BKE_view_layer_base_find(layer, cob->ob);
TreeElement *te_object = outliner_add_element(soops, tree, base->object, ten, 0, 0);
te_object->directdata = base;
@@ -1405,7 +1405,7 @@ static void outliner_add_layer_collections_recursive(SpaceOutliner *soops,
TreeElement *parent_ten,
const bool show_objects)
{
- for (LayerCollection *lc = layer_collections->first; lc; lc = lc->next) {
+ LISTBASE_FOREACH (LayerCollection *, lc, layer_collections) {
const bool exclude = (lc->flag & LAYER_COLLECTION_EXCLUDE) != 0;
TreeElement *ten;
@@ -1468,7 +1468,7 @@ BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *soops,
Collection *collection,
TreeElement *parent)
{
- for (CollectionObject *cob = collection->gobject.first; cob; cob = cob->next) {
+ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) {
outliner_add_element(soops, tree, cob->ob, parent, 0, 0);
}
}
@@ -1479,7 +1479,7 @@ static TreeElement *outliner_add_collection_recursive(SpaceOutliner *soops,
{
outliner_add_collection_init(ten, collection);
- for (CollectionChild *child = collection->children.first; child; child = child->next) {
+ LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
outliner_add_element(soops, &ten->subtree, &child->collection->id, ten, 0, 0);
}
@@ -1542,7 +1542,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo
continue;
}
- for (LinkData *link = parent_ob_tree_elements->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, parent_ob_tree_elements) {
TreeElement *parent_ob_tree_element = link->data;
TreeElement *parent_ob_collection_tree_element = NULL;
bool found = false;
@@ -1556,8 +1556,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo
parent_ob_collection_tree_element = parent_ob_collection_tree_element->parent;
}
- for (LinkData *link_iter = child_ob_tree_elements->first; link_iter;
- link_iter = link_iter->next) {
+ LISTBASE_FOREACH (LinkData *, link_iter, child_ob_tree_elements) {
TreeElement *child_ob_tree_element = link_iter->data;
if (child_ob_tree_element->parent == parent_ob_collection_tree_element) {
@@ -1589,7 +1588,7 @@ static void outliner_make_object_parent_hierarchy_collections(SpaceOutliner *soo
static void outliner_object_tree_elements_lookup_create_recursive(GHash *object_tree_elements_hash,
TreeElement *te_parent)
{
- for (TreeElement *te = te_parent->subtree.first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, &te_parent->subtree) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == TSE_LAYER_COLLECTION) {
@@ -2427,7 +2426,7 @@ void outliner_build_tree(
else if (soops->outlinevis == SO_VIEW_LAYER) {
if (soops->filter & SO_FILTER_NO_COLLECTION) {
/* Show objects in the view layer. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
TreeElement *te_object = outliner_add_element(
soops, &soops->tree, base->object, NULL, 0, 0);
te_object->directdata = base;
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 188a4e64897..a058c30cef2 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -78,7 +78,7 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
const ListBase *tree,
float view_co_y)
{
- for (TreeElement *te_iter = tree->first; te_iter; te_iter = te_iter->next) {
+ LISTBASE_FOREACH (TreeElement *, te_iter, tree) {
if (view_co_y < (te_iter->ys + UI_UNIT_Y)) {
if (view_co_y >= te_iter->ys) {
/* co_y is inside this element */
@@ -204,7 +204,7 @@ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse)
/* Find treestore that refers to given ID */
TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type == 0) {
if (tselem->id == id) {
@@ -222,7 +222,7 @@ TreeElement *outliner_find_id(SpaceOutliner *soops, ListBase *lb, const ID *id)
TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
if (te->directdata == pchan) {
return te;
}
@@ -240,7 +240,7 @@ TreeElement *outliner_find_posechannel(ListBase *lb, const bPoseChannel *pchan)
TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
if (te->directdata == ebone) {
return te;
}
@@ -361,7 +361,7 @@ float outliner_restrict_columns_width(const SpaceOutliner *soops)
/* Find first tree element in tree with matching treestore flag */
TreeElement *outliner_find_element_with_flag(const ListBase *lb, short flag)
{
- for (TreeElement *te = lb->first; te; te = te->next) {
+ LISTBASE_FOREACH (TreeElement *, te, lb) {
if ((TREESTORE(te)->flag & flag) == flag) {
return te;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 98565c7cc58..82331545a77 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -3477,7 +3477,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
seqbase_clipboard_frame = scene->r.cfra;
/* Need to remove anything that references the current scene */
- for (Sequence *seq = seqbase_clipboard.first; seq; seq = seq->next) {
+ LISTBASE_FOREACH (Sequence *, seq, &seqbase_clipboard) {
seq_copy_del_sound(scene, seq);
}
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index ccb18331c55..810e1009ecb 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -962,7 +962,7 @@ static int sequencer_select_side_exec(bContext *C, wmOperator *op)
copy_vn_i(frame_ranges, ARRAY_SIZE(frame_ranges), frame_init);
- for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) {
+ LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
if (UNLIKELY(seq->machine >= MAXSEQ)) {
continue;
}
@@ -1037,7 +1037,7 @@ static int sequencer_box_select_exec(bContext *C, wmOperator *op)
WM_operator_properties_border_to_rctf(op, &rectf);
UI_view2d_region_to_view_rctf(v2d, &rectf, &rectf);
- for (Sequence *seq = ed->seqbasep->first; seq; seq = seq->next) {
+ LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
rctf rq;
seq_rectf(seq, &rq);
if (BLI_rctf_isect(&rq, &rectf, NULL)) {
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 75717213cb1..226e6617a71 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -146,7 +146,7 @@ bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion
BLI_assert(v3d->spacetype == SPACE_VIEW3D);
- for (ARegion *region = region_list->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, region_list) {
/* find the first unlocked rv3d */
if (region->regiondata && region->regiontype == RGN_TYPE_WINDOW) {
rv3d = region->regiondata;
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 699ad40da9c..c1995249c26 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2396,7 +2396,7 @@ void ED_view3d_screen_datamask(const bContext *C,
CustomData_MeshMasks_update(r_cddata_masks, &CD_MASK_BAREMESH);
/* Check if we need tfaces & mcols due to view mode. */
- for (const ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (const ScrArea *, area, &screen->areabase) {
if (area->spacetype == SPACE_VIEW3D) {
ED_view3d_datamask(C, scene, area->spacedata.first, r_cddata_masks);
}
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index cd7db2ff23a..0a272db1344 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -157,7 +157,7 @@ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d)
{
bool changed = false;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->flag & BASE_SELECTED) {
if (BASE_SELECTABLE(v3d, base)) {
ED_object_base_select(base, BA_DESELECT);
@@ -172,7 +172,7 @@ static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d)
static bool object_deselect_all_except(ViewLayer *view_layer, Base *b)
{
bool changed = false;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->flag & BASE_SELECTED) {
if (b != base) {
ED_object_base_select(base, BA_DESELECT);
@@ -617,7 +617,7 @@ static Base **do_pose_tag_select_op_prepare(ViewContext *vc, uint *r_bases_len)
FOREACH_BASE_IN_MODE_BEGIN (vc->view_layer, vc->v3d, OB_ARMATURE, OB_MODE_POSE, base_iter) {
Object *ob_iter = base_iter->object;
bArmature *arm = ob_iter->data;
- for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_iter->pose->chanbase) {
Bone *bone = pchan->bone;
bone->flag &= ~BONE_DONE;
}
@@ -659,7 +659,7 @@ static bool do_pose_tag_select_op_exec(Base **bases, const uint bases_len, const
}
bool changed = true;
- for (bPoseChannel *pchan = ob_iter->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob_iter->pose->chanbase) {
Bone *bone = pchan->bone;
if ((bone->flag & BONE_UNSELECTABLE) == 0) {
const bool is_select = bone->flag & BONE_SELECTED;
@@ -3076,7 +3076,7 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const
const int hits = view3d_opengl_select(
vc, vbuffer, 4 * (totobj + MAXPICKELEMS), rect, VIEW3D_SELECT_ALL, select_filter);
- for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &vc->view_layer->object_bases) {
base->object->id.tag &= ~LIB_TAG_DOIT;
}
@@ -3092,7 +3092,7 @@ static bool do_object_box_select(bContext *C, ViewContext *vc, rcti *rect, const
goto finally;
}
- for (Base *base = vc->view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &vc->view_layer->object_bases) {
if (BASE_SELECTABLE(v3d, base)) {
if ((base->object->runtime.select_id & 0x0000FFFF) != 0) {
BLI_array_append(bases, base);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index ca9845b0b6e..b90f7aa870e 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1390,7 +1390,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
MEM_freeN(v3d->localvd);
v3d->localvd = NULL;
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = region->regiondata;
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index af3cba65dda..1e751f67c9d 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1026,7 +1026,7 @@ static void posttrans_fcurve_clean(FCurve *fcu,
}
else {
/* Compute the average values for each retained keyframe */
- for (tRetainedKeyframe *rk = retained_keys.first; rk; rk = rk->next) {
+ LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) {
rk->val = rk->val / (float)rk->tot_count;
}
}
@@ -1754,8 +1754,7 @@ static void special_aftertrans_update__movieclip(bContext *C, TransInfo *t)
ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(&clip->tracking);
const int framenr = ED_space_clip_get_clip_frame_number(sc);
/* Update coordinates of modified plane tracks. */
- for (MovieTrackingPlaneTrack *plane_track = plane_tracks_base->first; plane_track;
- plane_track = plane_track->next) {
+ LISTBASE_FOREACH (MovieTrackingPlaneTrack *, plane_track, plane_tracks_base) {
bool do_update = false;
if (plane_track->flag & PLANE_TRACK_HIDDEN) {
continue;
@@ -2078,12 +2077,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
const int filter = ANIMFILTER_DATA_VISIBLE;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_GPFRAME) {
ale->id->tag |= LIB_TAG_DOIT;
}
}
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_GPFRAME) {
if (ale->id->tag & LIB_TAG_DOIT) {
ale->id->tag &= ~LIB_TAG_DOIT;
@@ -2109,12 +2108,12 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
const int filter = ANIMFILTER_DATA_VISIBLE;
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_MASKLAY) {
ale->id->tag |= LIB_TAG_DOIT;
}
}
- for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) {
+ LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
if (ale->datatype == ALE_MASKLAY) {
if (ale->id->tag & LIB_TAG_DOIT) {
ale->id->tag &= ~LIB_TAG_DOIT;
diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index 9136f9edacc..e52bd15b0d5 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -531,8 +531,7 @@ void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, Object *
unit_m4(flip_mtx);
flip_mtx[0][0] = -1;
- for (bPoseChannel *pchan_orig = ob->pose->chanbase.first; pchan_orig;
- pchan_orig = pchan_orig->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan_orig, &ob->pose->chanbase) {
/* Clear the MIRROR flag from previous runs. */
pchan_orig->bone->flag &= ~BONE_TRANSFORM_MIRROR;
}
@@ -655,7 +654,7 @@ void createTransPose(TransInfo *t)
if (mirror) {
int total_mirrored = 0;
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if ((pchan->bone->flag & BONE_TRANSFORM) &&
BKE_pose_channel_get_mirrored(ob->pose, pchan->name)) {
total_mirrored++;
@@ -705,7 +704,7 @@ void createTransPose(TransInfo *t)
}
if (mirror) {
- for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
if (pchan->bone->flag & BONE_TRANSFORM) {
bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan->name);
if (pchan_mirror) {
@@ -727,7 +726,7 @@ void createTransPose(TransInfo *t)
/* use pose channels to fill trans data */
td = tc->data;
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
if (pchan->bone->flag & BONE_TRANSFORM) {
add_pose_transdata(t, pchan, ob, tc, td);
td++;
diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c
index 18211eb447f..908cf7707f2 100644
--- a/source/blender/editors/transform/transform_convert_curve.c
+++ b/source/blender/editors/transform/transform_convert_curve.c
@@ -99,7 +99,7 @@ void createTransCurveVerts(TransInfo *t)
/* count total of vertices, check identical as in 2nd loop for making transdata! */
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- for (Nurb *nu = nurbs->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
for (a = 0, bezt = nu->bezt; a < nu->pntsu; a++, bezt++) {
if (bezt->hide == 0) {
@@ -174,7 +174,7 @@ void createTransCurveVerts(TransInfo *t)
TransData *td = tc->data;
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
- for (Nurb *nu = nurbs->first; nu; nu = nu->next) {
+ LISTBASE_FOREACH (Nurb *, nu, nurbs) {
if (nu->type == CU_BEZIER) {
TransData *head, *tail;
head = tail = td;
diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c
index 4973b1cb268..9b76db7f265 100644
--- a/source/blender/editors/transform/transform_convert_object.c
+++ b/source/blender/editors/transform/transform_convert_object.c
@@ -290,7 +290,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
static void trans_object_base_deps_flag_prepare(ViewLayer *view_layer)
{
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->object->id.tag &= ~LIB_TAG_DOIT;
}
}
@@ -324,7 +324,7 @@ static void trans_object_base_deps_flag_finish(const TransInfo *t, ViewLayer *vi
{
if ((t->options & CTX_OBMODE_XFORM_OBDATA) == 0) {
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (base->object->id.tag & LIB_TAG_DOIT) {
base->flag_legacy |= BA_SNAP_FIX_DEPS_FIASCO;
}
@@ -355,7 +355,7 @@ static void set_trans_object_base_flags(TransInfo *t)
/* Clear all flags we need. It will be used to detect dependencies. */
trans_object_base_deps_flag_prepare(view_layer);
/* Traverse all bases and set all possible flags. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
base->flag_legacy &= ~(BA_WAS_SEL | BA_TRANSFORM_LOCKED_IN_PLACE);
if (BASE_SELECTED_EDITABLE(v3d, base)) {
Object *ob = base->object;
@@ -422,7 +422,7 @@ static int count_proportional_objects(TransInfo *t)
if (!((t->around == V3D_AROUND_LOCAL_ORIGINS) &&
(t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))) {
/* Mark all parents. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
if (BASE_SELECTED_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) {
Object *parent = base->object->parent;
/* flag all parents */
@@ -433,7 +433,7 @@ static int count_proportional_objects(TransInfo *t)
}
}
/* Mark all children. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
/* all base not already selected or marked that is editable */
if ((base->object->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
(base->flag & BASE_SELECTED) == 0 &&
@@ -443,7 +443,7 @@ static int count_proportional_objects(TransInfo *t)
}
}
/* Flush changed flags to all dependencies. */
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
/* If base is not selected, not a parent of selection or not a child of
* selection and it is editable and selectable.
@@ -592,7 +592,7 @@ void createTransObject(bContext *C, TransInfo *t)
ViewLayer *view_layer = t->view_layer;
View3D *v3d = t->view;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
/* if base is not selected, not a parent of selection
@@ -639,7 +639,7 @@ void createTransObject(bContext *C, TransInfo *t)
ViewLayer *view_layer = t->view_layer;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (ob->parent != NULL) {
if (ob->parent && !BLI_gset_haskey(objects_in_transdata, ob->parent) &&
@@ -669,7 +669,7 @@ void createTransObject(bContext *C, TransInfo *t)
}
}
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if (BASE_XFORM_INDIRECT(base) || BLI_gset_haskey(objects_in_transdata, ob)) {
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index 6af1989a509..aa298b04d1a 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -800,7 +800,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
/* calculate difference matrix */
BKE_gpencil_parent_matrix_get(depsgraph, ob, gpl, diff_mat);
- for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpl->actframe->strokes) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
@@ -883,7 +883,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
if (use_mat_local) {
mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat);
}
- for (EditBone *ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) {
if (EBONE_VISIBLE(arm, ebo)) {
if (ebo->flag & BONE_TIPSEL) {
calc_tw_center_with_matrix(tbounds, ebo->tail, use_mat_local, mat_local);
@@ -977,7 +977,7 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
mul_m4_m4m4(mat_local, obedit->imat, ob_iter->obmat);
}
- for (MetaElem *ml = mb->editelems->first; ml; ml = ml->next) {
+ LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
if (ml->flag & SELECT) {
calc_tw_center_with_matrix(tbounds, &ml->x, use_mat_local, mat_local);
totsel++;
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 8e7e36d7cb7..2cfeedbb346 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -1838,7 +1838,7 @@ static short snapArmature(SnapData *snapdata,
bArmature *arm = ob->data;
if (arm->edbo) {
- for (EditBone *eBone = arm->edbo->first; eBone; eBone = eBone->next) {
+ LISTBASE_FOREACH (EditBone *, eBone, arm->edbo) {
if (eBone->layer & arm->layer) {
/* skip hidden or moving (selected) bones */
if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
@@ -1881,7 +1881,7 @@ static short snapArmature(SnapData *snapdata,
}
}
else if (ob->pose && ob->pose->chanbase.first) {
- for (bPoseChannel *pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
Bone *bone = pchan->bone;
/* skip hidden bones */
if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 39ecbad1807..69e7c04b5e5 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -816,7 +816,7 @@ static int undo_editmode_objects_from_view_layer_prepare(ViewLayer *view_layer,
{
const short object_type = obact->type;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
@@ -825,7 +825,7 @@ static int undo_editmode_objects_from_view_layer_prepare(ViewLayer *view_layer,
}
int len = 0;
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
if (ob == obact) {
@@ -852,7 +852,7 @@ Object **ED_undo_editmode_objects_from_view_layer(ViewLayer *view_layer, uint *r
const short object_type = obact->type;
int i = 0;
Object **objects = MEM_malloc_arrayN(len, sizeof(*objects), __func__);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
@@ -881,7 +881,7 @@ Base **ED_undo_editmode_bases_from_view_layer(ViewLayer *view_layer, uint *r_len
const short object_type = obact->type;
int i = 0;
Base **base_array = MEM_malloc_arrayN(len, sizeof(*base_array), __func__);
- for (Base *base = view_layer->object_bases.first; base; base = base->next) {
+ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
Object *ob = base->object;
if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
ID *id = ob->data;
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index 733cdad2212..f8e19b742e4 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -83,7 +83,7 @@
void ED_editors_init_for_undo(Main *bmain)
{
wmWindowManager *wm = bmain->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);
Base *base = BASACT(view_layer);
if (base != NULL) {
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c
index e00b6f78c2e..e322b9fb9b8 100644
--- a/source/blender/gpu/intern/gpu_batch_presets.c
+++ b/source/blender/gpu/intern/gpu_batch_presets.c
@@ -241,7 +241,7 @@ void gpu_batch_presets_reset(void)
BLI_mutex_lock(&g_presets_3d.mutex);
/* Reset vao caches for these every time we switch opengl context.
* This way they will draw correctly for each window. */
- for (LinkData *link = presets_list.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &presets_list) {
GPUBatch *preset = link->data;
GPU_batch_vao_cache_clear(preset);
}
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index f279ab2c86c..8a46e24d459 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -75,7 +75,7 @@ static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, ListBase *
BLI_HashMurmur2A hm2a;
BLI_hash_mm2a_init(&hm2a, 0);
BLI_hash_mm2a_add(&hm2a, (uchar *)frag_gen, strlen(frag_gen));
- for (GPUMaterialAttribute *attr = attributes->first; attr; attr = attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, attributes) {
BLI_hash_mm2a_add(&hm2a, (uchar *)attr->name, strlen(attr->name));
}
if (defs) {
@@ -314,12 +314,12 @@ static int codegen_process_uniforms_functions(GPUMaterial *material,
ListBase ubo_inputs = {NULL, NULL};
/* Attributes */
- for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
BLI_dynstr_appendf(ds, "in %s var%d;\n", gpu_data_type_to_string(attr->gputype), attr->id);
}
/* Textures */
- for (GPUMaterialTexture *tex = graph->textures.first; tex; tex = tex->next) {
+ LISTBASE_FOREACH (GPUMaterialTexture *, tex, &graph->textures) {
if (tex->colorband) {
BLI_dynstr_appendf(ds, "uniform sampler1DArray %s;\n", tex->sampler_name);
}
@@ -333,7 +333,7 @@ static int codegen_process_uniforms_functions(GPUMaterial *material,
}
/* Volume Grids */
- for (GPUMaterialVolumeGrid *grid = graph->volume_grids.first; grid; grid = grid->next) {
+ LISTBASE_FOREACH (GPUMaterialVolumeGrid *, grid, &graph->volume_grids) {
BLI_dynstr_appendf(ds, "uniform sampler3D %s;\n", grid->sampler_name);
BLI_dynstr_appendf(ds, "uniform mat4 %s = mat4(0.0);\n", grid->transform_name);
}
@@ -381,7 +381,7 @@ static int codegen_process_uniforms_functions(GPUMaterial *material,
/* Inputs are sorted */
BLI_dynstr_appendf(ds, "\nlayout (std140) uniform %s {\n", GPU_UBO_BLOCK_NAME);
- for (LinkData *link = ubo_inputs.first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, &ubo_inputs) {
input = link->data;
BLI_dynstr_appendf(ds, "\t%s unf%d;\n", gpu_data_type_to_string(input->type), input->id);
}
@@ -673,7 +673,7 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo
"#define DEFINE_ATTR(type, attr) in type attr\n"
"#endif\n");
- for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
/* XXX FIXME : see notes in mesh_render_data_create() */
/* NOTE : Replicate changes to mesh_render_data_create() in draw_cache_impl_mesh.c */
if (attr->type == CD_ORCO) {
@@ -787,7 +787,7 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo
BLI_dynstr_append(ds, "\tbarycentricPosg = position;\n");
}
- for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
if (attr->type == CD_TANGENT) {
/* Not supported by hairs */
BLI_dynstr_appendf(ds, "\tvar%d%s = vec4(0.0);\n", attr->id, use_geom ? "g" : "");
@@ -820,7 +820,7 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo
BLI_dynstr_append(ds, "\tbarycentricPosg = (ModelMatrix * vec4(position, 1.0)).xyz;\n");
}
- for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
if (attr->type == CD_TANGENT) { /* silly exception */
BLI_dynstr_appendf(ds,
"\tvar%d%s.xyz = transpose(mat3(ModelMatrixInverse)) * att%d.xyz;\n",
@@ -903,7 +903,7 @@ static char *code_generate_geometry(GPUNodeGraph *graph,
}
}
- for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
BLI_dynstr_appendf(ds, "in %s var%dg[];\n", gpu_data_type_to_string(attr->gputype), attr->id);
BLI_dynstr_appendf(ds, "out %s var%d;\n", gpu_data_type_to_string(attr->gputype), attr->id);
}
@@ -1010,7 +1010,7 @@ static char *code_generate_geometry(GPUNodeGraph *graph,
BLI_dynstr_append(ds, "#endif\n");
}
- for (GPUMaterialAttribute *attr = graph->attributes.first; attr; attr = attr->next) {
+ LISTBASE_FOREACH (GPUMaterialAttribute *, attr, &graph->attributes) {
/* TODO let shader choose what to do depending on what the attribute is. */
BLI_dynstr_appendf(ds, "\tvar%d = var%dg[vert];\n", attr->id, attr->id);
}
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 3e73d156440..97e4c880644 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -191,7 +191,7 @@ static void gpu_material_free_single(GPUMaterial *material)
void GPU_material_free(ListBase *gpumaterial)
{
- for (LinkData *link = gpumaterial->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, gpumaterial) {
GPUMaterial *material = link->data;
gpu_material_free_single(material);
MEM_freeN(material);
@@ -628,7 +628,7 @@ GPUMaterial *GPU_material_from_nodetree_find(ListBase *gpumaterials,
const void *engine_type,
int options)
{
- for (LinkData *link = gpumaterials->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, gpumaterials) {
GPUMaterial *current_material = (GPUMaterial *)link->data;
if (current_material->engine_type == engine_type && current_material->options == options) {
return current_material;
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index 953b2eb40d8..876a6bef670 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -645,7 +645,7 @@ void gpu_node_graph_free(GPUNodeGraph *graph)
{
gpu_node_graph_free_nodes(graph);
- for (GPUMaterialVolumeGrid *grid = graph->volume_grids.first; grid; grid = grid->next) {
+ LISTBASE_FOREACH (GPUMaterialVolumeGrid *, grid, &graph->volume_grids) {
MEM_SAFE_FREE(grid->name);
}
BLI_freelistN(&graph->volume_grids);
@@ -679,7 +679,7 @@ static void gpu_nodes_tag(GPUNodeLink *link)
void gpu_node_graph_prune_unused(GPUNodeGraph *graph)
{
- for (GPUNode *node = graph->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (GPUNode *, node, &graph->nodes) {
node->tag = false;
}
diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c
index 56fe1e40d87..674ca06d109 100644
--- a/source/blender/gpu/intern/gpu_select_pick.c
+++ b/source/blender/gpu/intern/gpu_select_pick.c
@@ -731,8 +731,7 @@ void gpu_select_pick_cache_load_id(void)
#ifdef DEBUG_PRINT
printf("%s (building depth from cache)\n", __func__);
#endif
- for (DepthBufCache *rect_depth = ps->cache.bufs.first; rect_depth;
- rect_depth = rect_depth->next) {
+ LISTBASE_FOREACH (DepthBufCache *, rect_depth, &ps->cache.bufs) {
if (rect_depth->next != NULL) {
/* we know the buffers differ, but this sub-region may not.
* double check before adding an id-pass */
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.c b/source/blender/gpu/intern/gpu_uniformbuffer.c
index 943793956d1..130e8fe7da1 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.c
+++ b/source/blender/gpu/intern/gpu_uniformbuffer.c
@@ -147,7 +147,7 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou
/* Make sure we comply to the ubo alignment requirements. */
gpu_uniformbuffer_inputs_sort(inputs);
- for (LinkData *link = inputs->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, inputs) {
const eGPUType gputype = get_padded_gpu_type(link);
ubo->buffer.size += gputype * sizeof(float);
}
@@ -160,7 +160,7 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou
/* Now that we know the total ubo size we can start populating it. */
float *offset = ubo->data;
- for (LinkData *link = inputs->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, inputs) {
GPUInput *input = link->data;
memcpy(offset, input->vec, input->type * sizeof(float));
offset += get_padded_gpu_type(link);
@@ -272,7 +272,7 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
LinkData *inputs_lookup[MAX_UBO_GPU_TYPE + 1] = {NULL};
eGPUType cur_type = MAX_UBO_GPU_TYPE + 1;
- for (LinkData *link = inputs->first; link; link = link->next) {
+ LISTBASE_FOREACH (LinkData *, link, inputs) {
GPUInput *input = link->data;
if (input->type == GPU_MAT3) {
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index 57efaf99b8b..b2e1cb17946 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -355,7 +355,7 @@ GPUTexture *GPU_viewport_texture_pool_query(
{
GPUTexture *tex;
- for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex->next) {
+ LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) {
if ((GPU_texture_format(tmp_tex->texture) == format) &&
(GPU_texture_width(tmp_tex->texture) == width) &&
(GPU_texture_height(tmp_tex->texture) == height)) {
@@ -412,7 +412,7 @@ static void gpu_viewport_texture_pool_clear_users(GPUViewport *viewport)
static void gpu_viewport_texture_pool_free(GPUViewport *viewport)
{
- for (ViewportTempTexture *tmp_tex = viewport->tex_pool.first; tmp_tex; tmp_tex = tmp_tex->next) {
+ LISTBASE_FOREACH (ViewportTempTexture *, tmp_tex, &viewport->tex_pool) {
GPU_texture_free(tmp_tex->texture);
}
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index b72c32a8277..3646686e81f 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -654,7 +654,7 @@ void iksolver_release_tree(struct Scene *UNUSED(scene), struct Object *ob, float
void iksolver_clear_data(bPose *pose)
{
- for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
if ((pchan->flag & POSE_IKTREE) == 0) {
continue;
}
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, &region->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;
}
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index d9fe2504e22..d36fce3752b 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -124,8 +124,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
/* Add relation from canvases to all brush objects. */
if (pmd->canvas != NULL && pmd->type == MOD_DYNAMICPAINT_TYPE_CANVAS) {
- for (DynamicPaintSurface *surface = pmd->canvas->surfaces.first; surface;
- surface = surface->next) {
+ LISTBASE_FOREACH (DynamicPaintSurface *, surface, &pmd->canvas->surfaces) {
if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
DEG_add_forcefield_relations(
ctx->node, ctx->object, surface->effector_weights, true, 0, "Dynamic Paint Field");
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index f79edcadbda..d44cb8c7de1 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -229,7 +229,7 @@ bNode *ntreeShaderOutputNode(bNodeTree *ntree, int target)
* multiple, we prefer exact target match and active nodes. */
bNode *output_node = NULL;
- for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (!ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT)) {
continue;
}
@@ -344,7 +344,7 @@ static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSoc
bool removed_link = false;
for (node = group_ntree->nodes.first; node; node = node->next) {
- for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if ((sock->flag & SOCK_HIDE_VALUE) == 0) {
continue;
}
@@ -553,7 +553,7 @@ static void ntree_shader_relink_node_normal(bNodeTree *ntree,
/* TODO(sergey): Can we do something smarter here than just a name-based
* matching?
*/
- for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (STREQ(sock->identifier, "Normal") && sock->link == NULL) {
/* It's a normal input and nothing is connected to it. */
nodeAddLink(ntree, node_from, socket_from, node, sock);
diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.c b/source/blender/nodes/shader/nodes/node_shader_displacement.c
index 496b61c8c72..22fbe4e4da6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_displacement.c
+++ b/source/blender/nodes/shader/nodes/node_shader_displacement.c
@@ -39,7 +39,7 @@ static void node_shader_init_displacement(bNodeTree *UNUSED(ntree), bNode *node)
node->custom1 = SHD_SPACE_OBJECT; /* space */
/* Set default value here for backwards compatibility. */
- for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (STREQ(sock->name, "Midlevel")) {
((bNodeSocketValueFloat *)sock->default_value)->value = 0.5f;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
index eba9abc6e3c..1b802f1dfd7 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c
@@ -135,7 +135,7 @@ static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = tex;
- for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (STREQ(sock->name, "Mortar Smooth")) {
((bNodeSocketValueFloat *)sock->default_value)->value = 0.1f;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
index 92e1b3435c8..b581a4bd3a6 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
@@ -44,7 +44,7 @@ static bNodeSocketTemplate sh_node_volume_principled_out[] = {
static void node_shader_init_volume_principled(bNodeTree *UNUSED(ntree), bNode *node)
{
- for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (STREQ(sock->name, "Density Attribute")) {
strcpy(((bNodeSocketValueString *)sock->default_value)->value, "density");
}
@@ -66,7 +66,7 @@ static int node_shader_gpu_volume_principled(GPUMaterial *mat,
/* Get volume attributes. */
GPUNodeLink *density = NULL, *color = NULL, *temperature = NULL;
- for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
+ LISTBASE_FOREACH (bNodeSocket *, sock, &node->inputs) {
if (sock->typeinfo->type != SOCK_STRING) {
continue;
}
diff --git a/source/blender/python/intern/bpy_capi_utils.c b/source/blender/python/intern/bpy_capi_utils.c
index 3a77e1ba797..89ef2f40a30 100644
--- a/source/blender/python/intern/bpy_capi_utils.c
+++ b/source/blender/python/intern/bpy_capi_utils.c
@@ -92,7 +92,7 @@ void BPy_reports_write_stdout(const ReportList *reports, const char *header)
PySys_WriteStdout("%s\n", header);
}
- for (const Report *report = reports->list.first; report; report = report->next) {
+ LISTBASE_FOREACH (const Report *, report, &reports->list) {
PySys_WriteStdout("%s: %s\n", report->typestr, report->message);
}
}
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 1a97332212d..f7901ebb7d0 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -2095,14 +2095,13 @@ void RE_RenderFreestyleExternal(Render *re)
FRS_init_stroke_renderer(re);
- for (RenderView *rv = re->result->views.first; rv; rv = rv->next) {
+ LISTBASE_FOREACH (RenderView *, rv, &re->result->views) {
RE_SetActiveRenderView(re, rv->name);
ViewLayer *active_view_layer = BLI_findlink(&re->view_layers, re->active_view_layer);
FRS_begin_stroke_rendering(re);
- for (ViewLayer *view_layer = (ViewLayer *)re->view_layers.first; view_layer;
- view_layer = view_layer->next) {
+ LISTBASE_FOREACH (ViewLayer *, view_layer, &re->view_layers) {
if ((re->r.scemode & R_SINGLE_LAYER) && view_layer != active_view_layer) {
continue;
}
@@ -2866,7 +2865,7 @@ bool RE_layers_have_name(struct RenderResult *rr)
bool RE_passes_have_name(struct RenderLayer *rl)
{
- for (RenderPass *rp = rl->passes.first; rp; rp = rp->next) {
+ LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) {
if (!STREQ(rp->name, "Combined")) {
return true;
}
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 814e9b1c79e..b38c1b573f3 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -917,7 +917,7 @@ bool RE_WriteRenderResult(ReportList *reports,
/* First add views since IMB_exr_add_channel checks number of views. */
if (render_result_has_views(rr)) {
- for (RenderView *rview = rr->views.first; rview; rview = rview->next) {
+ LISTBASE_FOREACH (RenderView *, rview, &rr->views) {
if (!view || STREQ(view, rview->name)) {
IMB_exr_add_view(exrhandle, rview->name);
}
@@ -926,7 +926,7 @@ bool RE_WriteRenderResult(ReportList *reports,
/* Compositing result. */
if (rr->have_combined) {
- for (RenderView *rview = rr->views.first; rview; rview = rview->next) {
+ LISTBASE_FOREACH (RenderView *, rview, &rr->views) {
if (!rview->rectf) {
continue;
}
@@ -986,7 +986,7 @@ bool RE_WriteRenderResult(ReportList *reports,
continue;
}
- for (RenderPass *rp = rl->passes.first; rp; rp = rp->next) {
+ LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) {
/* Skip non-RGBA and Z passes if not using multi layer. */
if (!multi_layer && !(STREQ(rp->name, RE_PASSNAME_COMBINED) || STREQ(rp->name, "") ||
(STREQ(rp->name, RE_PASSNAME_Z) && write_z))) {
@@ -1240,7 +1240,7 @@ void render_result_exr_file_begin(Render *re, RenderEngine *engine)
char str[FILE_MAX];
for (RenderResult *rr = re->result; rr; rr = rr->next) {
- for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next) {
+ LISTBASE_FOREACH (RenderLayer *, rl, &rr->layers) {
/* Get passes needed by engine. Normally we would wait for the
* engine to create them, but for EXR file we need to know in
* advance. */
@@ -1250,7 +1250,7 @@ void render_result_exr_file_begin(Render *re, RenderEngine *engine)
/* Create render passes requested by engine. Only this part is
* mutex locked to avoid deadlock with Python GIL. */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- for (RenderPass *pass = templates.first; pass; pass = pass->next) {
+ LISTBASE_FOREACH (RenderPass *, pass, &templates) {
RE_create_render_pass(
re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL);
}
@@ -1271,7 +1271,7 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine)
{
/* Close EXR files. */
for (RenderResult *rr = re->result; rr; rr = rr->next) {
- for (RenderLayer *rl = rr->layers.first; rl; rl = rl->next) {
+ LISTBASE_FOREACH (RenderLayer *, rl, &rr->layers) {
IMB_exr_close(rl->exrhandle);
rl->exrhandle = NULL;
}
@@ -1285,7 +1285,7 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine)
re->result = render_result_new(re, &re->disprect, 0, RR_USE_MEM, RR_ALL_LAYERS, RR_ALL_VIEWS);
BLI_rw_mutex_unlock(&re->resultmutex);
- for (RenderLayer *rl = re->result->layers.first; rl; rl = rl->next) {
+ LISTBASE_FOREACH (RenderLayer *, rl, &re->result->layers) {
/* Get passes needed by engine. */
ListBase templates;
render_result_get_pass_templates(engine, re, rl, &templates);
@@ -1293,7 +1293,7 @@ void render_result_exr_file_end(Render *re, RenderEngine *engine)
/* Create render passes requested by engine. Only this part is
* mutex locked to avoid deadlock with Python GIL. */
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
- for (RenderPass *pass = templates.first; pass; pass = pass->next) {
+ LISTBASE_FOREACH (RenderPass *, pass, &templates) {
RE_create_render_pass(re->result, pass->name, pass->channels, pass->chan_id, rl->name, NULL);
}
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
index 90a3234abd5..67f30f0d7ee 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c
@@ -222,7 +222,7 @@ wmGizmo *wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm,
{
int gzgroup_keymap_uses_modifier = -1;
- for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
if (gz->type->test_select && (gz->flag & (WM_GIZMO_HIDDEN | WM_GIZMO_HIDDEN_SELECT)) == 0) {
if (!wm_gizmo_keymap_uses_event_modifier(
@@ -299,9 +299,9 @@ void WM_gizmo_group_remove_by_tool(bContext *C,
{
wmGizmoMapType *gzmap_type = WM_gizmomaptype_find(&gzgt->gzmap_params);
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->runtime.tool == tref) {
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
wmGizmoMap *gzmap = region->gizmo_map;
if (gzmap && gzmap->type == gzmap_type) {
wmGizmoGroup *gzgroup, *gzgroup_next;
@@ -337,7 +337,7 @@ bool wm_gizmogroup_is_visible_in_drawstep(const wmGizmoGroup *gzgroup,
bool wm_gizmogroup_is_any_selected(const wmGizmoGroup *gzgroup)
{
if (gzgroup->type->flag & WM_GIZMOGROUPTYPE_SELECT) {
- for (const wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (const wmGizmo *, gz, &gzgroup->gizmos) {
if (gz->state & WM_GIZMO_STATE_SELECT) {
return true;
}
@@ -850,8 +850,7 @@ struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find_ptr(struct wmGizmoMapType
const wmGizmoGroupType *gzgt)
{
/* could use hash lookups as operator types do, for now simple search. */
- for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref;
- gzgt_ref = gzgt_ref->next) {
+ LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) {
if (gzgt_ref->type == gzgt) {
return gzgt_ref;
}
@@ -863,8 +862,7 @@ struct wmGizmoGroupTypeRef *WM_gizmomaptype_group_find(struct wmGizmoMapType *gz
const char *idname)
{
/* could use hash lookups as operator types do, for now simple search. */
- for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref;
- gzgt_ref = gzgt_ref->next) {
+ LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) {
if (STREQ(idname, gzgt_ref->type->idname)) {
return gzgt_ref;
}
@@ -909,10 +907,10 @@ void WM_gizmomaptype_group_init_runtime(const Main *bmain,
/* now create a gizmo for all existing areas */
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) {
ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
- for (ARegion *region = lb->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, lb) {
wmGizmoMap *gzmap = region->gizmo_map;
if (gzmap && gzmap->type == gzmap_type) {
WM_gizmomaptype_group_init_runtime_with_region(gzmap_type, gzgt, region);
@@ -964,10 +962,10 @@ void WM_gizmomaptype_group_unlink(bContext *C,
{
/* Free instances. */
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) {
ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
- for (ARegion *region = lb->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, lb) {
wmGizmoMap *gzmap = region->gizmo_map;
if (gzmap && gzmap->type == gzmap_type) {
wmGizmoGroup *gzgroup, *gzgroup_next;
@@ -1134,10 +1132,10 @@ void WM_gizmo_group_unlink_delayed_ptr_from_space(wmGizmoGroupType *gzgt,
wmGizmoMapType *gzmap_type,
ScrArea *area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
wmGizmoMap *gzmap = region->gizmo_map;
if (gzmap && gzmap->type == gzmap_type) {
- for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
if (gzgroup->type == gzgt) {
WM_gizmo_group_tag_remove(gzgroup);
}
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index ae7475c3661..6ed6c485e89 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -171,8 +171,7 @@ static wmGizmoMap *wm_gizmomap_new_from_type_ex(struct wmGizmoMapType *gzmap_typ
/* create all gizmo-groups for this gizmo-map. We may create an empty one
* too in anticipation of gizmos from operators etc */
- for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref;
- gzgt_ref = gzgt_ref->next) {
+ LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) {
wm_gizmogroup_new_from_type(gzmap, gzgt_ref->type);
}
@@ -231,7 +230,7 @@ wmGizmoGroup *WM_gizmomap_group_find(struct wmGizmoMap *gzmap, const char *idnam
wmGizmoGroup *WM_gizmomap_group_find_ptr(struct wmGizmoMap *gzmap,
const struct wmGizmoGroupType *gzgt)
{
- for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
if (gzgroup->type == gzgt) {
return gzgroup;
}
@@ -290,9 +289,9 @@ static GHash *WM_gizmomap_gizmo_hash_new(const bContext *C,
GHash *hash = BLI_ghash_ptr_new(__func__);
/* collect gizmos */
- for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
if (WM_gizmo_group_type_poll(C, gzgroup->type)) {
- for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
if (((flag_exclude == 0) || ((gz->flag & flag_exclude) == 0)) &&
(!poll || poll(gz, data))) {
BLI_ghash_insert(hash, gz, gz);
@@ -335,7 +334,7 @@ void WM_gizmomap_tag_refresh(wmGizmoMap *gzmap)
bool WM_gizmomap_tag_delay_refresh_for_tweak_check(wmGizmoMap *gzmap)
{
- for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
if (gzgroup->hide.delay_refresh_for_tweak) {
return true;
}
@@ -403,7 +402,7 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap,
const bool do_refresh = gzmap->update_flag[drawstep] & GIZMOMAP_IS_REFRESH_CALLBACK;
gzmap->update_flag[drawstep] &= ~GIZMOMAP_IS_REFRESH_CALLBACK;
- for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
/* check group visibility - drawstep first to avoid unnecessary call of group poll callback */
if (!wm_gizmogroup_is_visible_in_drawstep(gzgroup, drawstep) ||
!WM_gizmo_group_type_poll(C, gzgroup->type)) {
@@ -430,7 +429,7 @@ static void gizmomap_prepare_drawing(wmGizmoMap *gzmap,
gzgroup->type->draw_prepare(C, gzgroup);
}
- for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
gizmo_prepare_drawing(gzmap, gz, C, draw_gizmos, drawstep);
}
}
@@ -751,7 +750,7 @@ wmGizmo *wm_gizmomap_highlight_find(wmGizmoMap *gzmap,
const int event_modifier = WM_event_modifier_flag(event);
- for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
/* If it were important we could initialize here,
* but this only happens when events are handled before drawing,
@@ -1165,12 +1164,12 @@ void WM_gizmomap_message_subscribe(bContext *C,
ARegion *region,
struct wmMsgBus *mbus)
{
- for (wmGizmoGroup *gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, &gzmap->groups) {
if ((gzgroup->hide.any != 0) || (gzgroup->init_flag & WM_GIZMOGROUP_INIT_SETUP) == 0 ||
!WM_gizmo_group_type_poll(C, gzgroup->type)) {
continue;
}
- for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
if (gz->flag & WM_GIZMO_HIDDEN) {
continue;
}
@@ -1220,8 +1219,7 @@ struct ARegion *WM_gizmomap_tooltip_init(struct bContext *C,
wmGizmoMapType *WM_gizmomaptype_find(const struct wmGizmoMapType_Params *gzmap_params)
{
- for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type;
- gzmap_type = gzmap_type->next) {
+ LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) {
if (gzmap_type->spaceid == gzmap_params->spaceid &&
gzmap_type->regionid == gzmap_params->regionid) {
return gzmap_type;
@@ -1269,10 +1267,8 @@ void wm_gizmos_keymap(wmKeyConfig *keyconf)
/* we add this item-less keymap once and use it to group gizmo-group keymaps into it */
WM_keymap_ensure(keyconf, "Gizmos", 0, 0);
- for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type;
- gzmap_type = gzmap_type->next) {
- for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref;
- gzgt_ref = gzgt_ref->next) {
+ LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) {
+ LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) {
wm_gizmogrouptype_setup_keymap(gzgt_ref->type, keyconf);
}
}
@@ -1328,8 +1324,7 @@ void WM_gizmoconfig_update(struct Main *bmain)
}
if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) {
- for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type;
- gzmap_type = gzmap_type->next) {
+ LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) {
if (gzmap_type->type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_REMOVE) {
gzmap_type->type_update_flag &= ~WM_GIZMOMAPTYPE_UPDATE_REMOVE;
for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first, *gzgt_ref_next;
@@ -1348,13 +1343,11 @@ void WM_gizmoconfig_update(struct Main *bmain)
}
if (wm_gzmap_type_update_flag & WM_GIZMOMAPTYPE_GLOBAL_UPDATE_INIT) {
- for (wmGizmoMapType *gzmap_type = gizmomaptypes.first; gzmap_type;
- gzmap_type = gzmap_type->next) {
+ LISTBASE_FOREACH (wmGizmoMapType *, gzmap_type, &gizmomaptypes) {
const uchar type_update_all = WM_GIZMOMAPTYPE_UPDATE_INIT | WM_GIZMOMAPTYPE_KEYMAP_INIT;
if (gzmap_type->type_update_flag & type_update_all) {
gzmap_type->type_update_flag &= ~type_update_all;
- for (wmGizmoGroupTypeRef *gzgt_ref = gzmap_type->grouptype_refs.first; gzgt_ref;
- gzgt_ref = gzgt_ref->next) {
+ LISTBASE_FOREACH (wmGizmoGroupTypeRef *, gzgt_ref, &gzmap_type->grouptype_refs) {
if (gzgt_ref->type->type_update_flag & WM_GIZMOMAPTYPE_KEYMAP_INIT) {
WM_gizmomaptype_group_init_runtime_keymap(bmain, gzgt_ref->type);
gzgt_ref->type->type_update_flag &= ~WM_GIZMOMAPTYPE_KEYMAP_INIT;
@@ -1373,11 +1366,11 @@ void WM_gizmoconfig_update(struct Main *bmain)
if (wm_gzmap_type_update_flag & WM_GIZMOTYPE_GLOBAL_UPDATE_REMOVE) {
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) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase :
&sl->regionbase;
- for (ARegion *region = regionbase->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, regionbase) {
wmGizmoMap *gzmap = region->gizmo_map;
if (gzmap != NULL && gzmap->tag_remove_group) {
gzmap->tag_remove_group = false;
@@ -1411,10 +1404,10 @@ void WM_gizmoconfig_update(struct Main *bmain)
void WM_reinit_gizmomap_all(Main *bmain)
{
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) {
ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
- for (ARegion *region = regionbase->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, regionbase) {
wmGizmoMap *gzmap = region->gizmo_map;
if ((gzmap != NULL) && (gzmap->is_init == false)) {
WM_gizmomap_reinit(gzmap);
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
index fe7de6739e1..3956ff8fd36 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c
@@ -135,10 +135,10 @@ static void gizmotype_unlink(bContext *C, Main *bmain, wmGizmoType *gzt)
{
/* Free instances. */
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) {
ListBase *lb = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase;
- for (ARegion *region = lb->first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, lb) {
wmGizmoMap *gzmap = region->gizmo_map;
if (gzmap) {
wmGizmoGroup *gzgroup;
diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c
index 44c8e8cd61e..ad3fc7a1302 100644
--- a/source/blender/windowmanager/intern/wm_dragdrop.c
+++ b/source/blender/windowmanager/intern/wm_dragdrop.c
@@ -204,7 +204,7 @@ static const char *dropbox_active(bContext *C,
if (handler_base->type == WM_HANDLER_TYPE_DROPBOX) {
wmEventHandler_Dropbox *handler = (wmEventHandler_Dropbox *)handler_base;
if (handler->dropboxes) {
- for (wmDropBox *drop = handler->dropboxes->first; drop; drop = drop->next) {
+ LISTBASE_FOREACH (wmDropBox *, drop, handler->dropboxes) {
const char *tooltip = NULL;
if (drop->poll(C, drag, event, &tooltip)) {
/* XXX Doing translation here might not be ideal, but later we have no more
@@ -290,7 +290,7 @@ void wm_drags_check_ops(bContext *C, const wmEvent *event)
void WM_drag_add_ID(wmDrag *drag, ID *id, ID *from_parent)
{
/* Don't drag the same ID twice. */
- for (wmDragID *drag_id = drag->ids.first; drag_id; drag_id = drag_id->next) {
+ LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
if (drag_id->id == id) {
if (drag_id->from_parent == NULL) {
drag_id->from_parent = from_parent;
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index bd255458ba8..d887d9b0eee 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -209,8 +209,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C,
}
wmGizmoMap *gzmap = region->gizmo_map;
- for (wmGizmoGroup *gzgroup = WM_gizmomap_group_list(gzmap)->first; gzgroup;
- gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, WM_gizmomap_group_list(gzmap)) {
if (tag_redraw && (gzgroup->type->flag & WM_GIZMOGROUPTYPE_VR_REDRAWS)) {
ScrArea *ctx_area = CTX_wm_area(C);
ARegion *ctx_region = CTX_wm_region(C);
@@ -227,7 +226,7 @@ static void wm_region_test_gizmo_do_draw(bContext *C,
CTX_wm_region_set(C, ctx_region);
}
- for (wmGizmo *gz = gzgroup->gizmos.first; gz; gz = gz->next) {
+ LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) {
if (gz->do_draw) {
if (tag_redraw) {
ED_region_tag_redraw_editor_overlays(region);
@@ -323,7 +322,7 @@ void *WM_draw_cb_activate(wmWindow *win,
void WM_draw_cb_exit(wmWindow *win, void *handle)
{
- for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) {
+ LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) {
if (wdc == (WindowDrawCB *)handle) {
BLI_remlink(&win->drawcalls, wdc);
MEM_freeN(wdc);
@@ -334,7 +333,7 @@ void WM_draw_cb_exit(wmWindow *win, void *handle)
static void wm_draw_callbacks(wmWindow *win)
{
- for (WindowDrawCB *wdc = win->drawcalls.first; wdc; wdc = wdc->next) {
+ LISTBASE_FOREACH (WindowDrawCB *, wdc, &win->drawcalls) {
wdc->draw(win, wdc->customdata);
}
}
@@ -624,7 +623,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
CTX_wm_area_set(C, area);
/* Compute UI layouts for dynamically size regions. */
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
/* Dynamic region may have been flagged as too small because their size on init is 0.
* ARegion.visible is false then, as expected. The layout should still be created then, so
* the region size can be updated (it may turn out to be not too small then). */
@@ -650,7 +649,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
}
/* Then do actual drawing of regions. */
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->visible && region->do_draw) {
CTX_wm_region_set(C, region);
bool use_viewport = wm_region_use_viewport(area, region);
@@ -694,7 +693,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo)
}
/* Draw menus into their own framebuffer. */
- for (ARegion *region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
if (region->visible) {
CTX_wm_menu_set(C, region);
@@ -737,7 +736,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
/* Blit non-overlapping area regions. */
ED_screen_areas_iter(win, screen, area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->visible && region->overlap == false) {
/* Blit from offscreen buffer. */
wm_draw_region_blit(region, view);
@@ -749,7 +748,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
if (wm->paintcursors.first) {
ED_screen_areas_iter(win, screen, area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->visible && region == screen->active_region) {
CTX_wm_area_set(C, area);
CTX_wm_region_set(C, region);
@@ -769,7 +768,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
/* Blend in overlapping area regions */
ED_screen_areas_iter(win, screen, area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->visible && region->overlap) {
wm_draw_region_blend(region, 0, true);
}
@@ -781,7 +780,7 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
wm_draw_callbacks(win);
/* Blend in floating regions (menus). */
- for (ARegion *region = screen->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) {
if (region->visible) {
wm_draw_region_blend(region, 0, true);
}
@@ -958,7 +957,7 @@ static void wm_draw_update_clear_window(bContext *C, wmWindow *win)
ED_screen_areas_iter(win, screen, area)
{
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
wm_region_test_gizmo_do_draw(C, area, region, false);
}
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 7645ac6fdcf..15b6fe53417 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -192,7 +192,7 @@ void wm_event_init_from_window(wmWindow *win, wmEvent *event)
static bool wm_test_duplicate_notifier(const wmWindowManager *wm, uint type, void *reference)
{
- for (wmNotifier *note = wm->queue.first; note; note = note->next) {
+ LISTBASE_FOREACH (wmNotifier *, note, &wm->queue) {
if ((note->category | note->data | note->subtype | note->action) == type &&
note->reference == reference) {
return 1;
@@ -329,14 +329,14 @@ void wm_event_do_depsgraph(bContext *C, bool is_after_open_file)
}
/* Combine datamasks so 1 win doesn't disable UV's in another [#26448]. */
CustomData_MeshMasks win_combine_v3d_datamask = {0};
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
const Scene *scene = WM_window_get_active_scene(win);
const bScreen *screen = WM_window_get_active_screen(win);
ED_view3d_screen_datamask(C, scene, screen, &win_combine_v3d_datamask);
}
/* Update all the dependency graphs of visible view layers. */
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
Main *bmain = CTX_data_main(C);
@@ -369,7 +369,7 @@ void wm_event_do_refresh_wm_and_depsgraph(bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
/* cached: editor refresh callbacks now, they get context */
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
const bScreen *screen = WM_window_get_active_screen(win);
ScrArea *area;
@@ -1867,7 +1867,7 @@ static wmKeyMapItem *wm_eventmatch_modal_keymap_items(const wmKeyMap *keymap,
wmOperator *op,
const wmEvent *event)
{
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
/* Should already be handled by #wm_user_modal_keymap_set_items. */
BLI_assert(kmi->propvalue_str[0] == '\0');
if (wm_eventmatch(event, kmi)) {
@@ -2405,7 +2405,7 @@ static int wm_handlers_do_keymap_with_keymap_handler(
PRINT("pass\n");
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
if (wm_eventmatch(event, kmi)) {
struct wmEventHandler_KeymapPost keymap_post = handler->post;
@@ -2610,7 +2610,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
event_test_tweak.type = EVT_TWEAK_L + (event->type - LEFTMOUSE);
event_test_tweak.val = KM_ANY;
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
if ((kmi->flag & KMI_INACTIVE) == 0) {
if (wm_eventmatch(&event_test_click, kmi) ||
wm_eventmatch(&event_test_click_drag, kmi) ||
@@ -2635,7 +2635,7 @@ static int wm_handlers_do_gizmo_handler(bContext *C,
if ((action & WM_HANDLER_BREAK) == 0) {
if (WM_gizmomap_is_any_selected(gzmap)) {
const ListBase *groups = WM_gizmomap_group_list(gzmap);
- for (wmGizmoGroup *gzgroup = groups->first; gzgroup; gzgroup = gzgroup->next) {
+ LISTBASE_FOREACH (wmGizmoGroup *, gzgroup, groups) {
if (wm_gizmogroup_is_any_selected(gzgroup)) {
wmKeyMap *keymap = WM_keymap_active(wm, gzgroup->type->keymap);
action |= wm_handlers_do_keymap_with_gizmo_handler(
@@ -3614,7 +3614,7 @@ wmKeyMap *WM_event_get_keymap_from_toolsystem_fallback(wmWindowManager *wm,
if (tref_rt->gizmo_group[0] != '\0' && tref_rt->keymap_fallback[0] != '\n') {
wmGizmoMap *gzmap = NULL;
wmGizmoGroup *gzgroup = NULL;
- for (ARegion *region = area->regionbase.first; region; region = region->next) {
+ LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
if (region->gizmo_map != NULL) {
gzmap = region->gizmo_map;
gzgroup = WM_gizmomap_group_find(gzmap, tref_rt->gizmo_group);
@@ -4774,7 +4774,7 @@ wmKeyMap *WM_event_get_keymap_from_handler(wmWindowManager *wm, wmEventHandler_K
wmKeyMapItem *WM_event_match_keymap_item(bContext *C, wmKeyMap *keymap, const wmEvent *event)
{
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
if (wm_eventmatch(event, kmi)) {
wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0);
if (WM_operator_poll_context(C, ot, WM_OP_INVOKE_DEFAULT)) {
@@ -4881,7 +4881,7 @@ ScrArea *WM_window_status_area_find(wmWindow *win, bScreen *screen)
return NULL;
}
ScrArea *area_statusbar = NULL;
- for (ScrArea *area = win->global_areas.areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
if (area->spacetype == SPACE_STATUSBAR) {
area_statusbar = area;
break;
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 3c8b6b1c9d4..95c7afcbf15 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -236,7 +236,7 @@ static void wm_window_match_keep_current_wm(const bContext *C,
/* when loading without UI, no matching needed */
if (load_ui && (screen = CTX_wm_screen(C))) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WorkSpace *workspace;
BKE_workspace_layout_find_global(bmain, screen, &workspace);
@@ -294,8 +294,8 @@ static void wm_window_match_replace_by_file_wm(bContext *C,
wm_window_clear_drawable(oldwm);
/* only first wm in list has ghostwins */
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
- for (wmWindow *oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
+ LISTBASE_FOREACH (wmWindow *, oldwin, &oldwm->windows) {
if (oldwin->winid == win->winid) {
has_match = true;
@@ -1507,7 +1507,7 @@ void wm_autosave_timer(Main *bmain, wmWindowManager *wm, wmTimer *UNUSED(wt))
WM_event_remove_timer(wm, NULL, wm->autosavetimer);
/* if a modal operator is running, don't autosave, but try again in 10 seconds */
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 33ea6dc54cc..245a8f28fec 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -254,7 +254,7 @@ static void wm_jobs_update_progress_bars(wmWindowManager *wm)
float total_progress = 0.f;
float jobs_progress = 0;
- for (wmJob *wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) {
+ LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) {
if (wm_job->threads.first && !wm_job->ready) {
if (wm_job->flag & WM_JOB_PROGRESS) {
/* accumulate global progress for running jobs */
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index 97a73d9dbfa..5f2b492088e 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -278,7 +278,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user
if (keyconf == wm->defaultconf) {
/* For default configuration, we need to keep keymap
* modal items and poll functions intact. */
- for (wmKeyMap *km = keyconf->keymaps.first; km; km = km->next) {
+ LISTBASE_FOREACH (wmKeyMap *, km, &keyconf->keymaps) {
WM_keymap_clear(km);
}
}
@@ -328,7 +328,7 @@ bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf)
void WM_keyconfig_clear(wmKeyConfig *keyconf)
{
- for (wmKeyMap *km = keyconf->keymaps.first; km; km = km->next) {
+ LISTBASE_FOREACH (wmKeyMap *, km, &keyconf->keymaps) {
WM_keymap_clear(km);
}
@@ -1329,7 +1329,7 @@ static wmKeyMapItem *wm_keymap_item_find_in_keymap(wmKeyMap *keymap,
const bool is_strict,
const struct wmKeyMapItemFind_Params *params)
{
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
/* skip disabled keymap items [T38447] */
if (kmi->flag & KMI_INACTIVE) {
continue;
diff --git a/source/blender/windowmanager/intern/wm_keymap_utils.c b/source/blender/windowmanager/intern/wm_keymap_utils.c
index 7d2d39963dd..5ab36b15666 100644
--- a/source/blender/windowmanager/intern/wm_keymap_utils.c
+++ b/source/blender/windowmanager/intern/wm_keymap_utils.c
@@ -486,7 +486,7 @@ static bool wm_keymap_item_uses_modifier(wmKeyMapItem *kmi, const int event_modi
bool WM_keymap_uses_event_modifier(wmKeyMap *keymap, const int event_modifier)
{
- for (wmKeyMapItem *kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ LISTBASE_FOREACH (wmKeyMapItem *, kmi, &keymap->items) {
if ((kmi->flag & KMI_INACTIVE) == 0) {
if (wm_keymap_item_uses_modifier(kmi, event_modifier)) {
return true;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 9a376390096..f8e020b00d0 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -769,7 +769,7 @@ bool WM_operator_last_properties_init(wmOperator *op)
bool changed = false;
if (op->type->last_properties) {
changed |= operator_last_properties_init_impl(op, op->type->last_properties);
- for (wmOperator *opm = op->macro.first; opm; opm = opm->next) {
+ LISTBASE_FOREACH (wmOperator *, opm, &op->macro) {
IDProperty *idp_src = IDP_GetPropertyFromGroup(op->type->last_properties, opm->idname);
if (idp_src) {
changed |= operator_last_properties_init_impl(opm, idp_src);
@@ -792,7 +792,7 @@ bool WM_operator_last_properties_store(wmOperator *op)
}
if (op->macro.first != NULL) {
- for (wmOperator *opm = op->macro.first; opm; opm = opm->next) {
+ LISTBASE_FOREACH (wmOperator *, opm, &op->macro) {
if (opm->properties) {
if (op->type->last_properties == NULL) {
op->type->last_properties = IDP_New(
@@ -3689,8 +3689,8 @@ static void wm_xr_session_update_screen(Main *bmain, const wmXrData *xr_data)
const bool session_exists = WM_xr_session_exists(xr_data);
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
- for (SpaceLink *slink = area->spacedata.first; slink; slink = slink->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+ LISTBASE_FOREACH (SpaceLink *, slink, &area->spacedata) {
if (slink->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)slink;
diff --git a/source/blender/windowmanager/intern/wm_surface.c b/source/blender/windowmanager/intern/wm_surface.c
index 043b584bbbd..e8850693d69 100644
--- a/source/blender/windowmanager/intern/wm_surface.c
+++ b/source/blender/windowmanager/intern/wm_surface.c
@@ -45,7 +45,7 @@ static wmSurface *g_drawable = NULL;
void wm_surfaces_iter(bContext *C, void (*cb)(bContext *C, wmSurface *))
{
- for (wmSurface *surf = global_surface_list.first; surf; surf = surf->next) {
+ LISTBASE_FOREACH (wmSurface *, surf, &global_surface_list) {
cb(C, surf);
}
}
diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c
index f1928819c26..38fa24f0416 100644
--- a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -178,7 +178,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
if (i != -1) {
const int value = items[i].value;
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (workspace == WM_window_get_active_workspace(win)) {
Scene *scene = WM_window_get_active_scene(win);
ToolSettings *ts = scene->toolsettings;
@@ -197,7 +197,7 @@ static void toolsystem_ref_link(bContext *C, WorkSpace *workspace, bToolRef *tre
if (i != -1) {
const int slot_index = items[i].value;
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (workspace == WM_window_get_active_workspace(win)) {
Scene *scene = WM_window_get_active_scene(win);
BKE_paint_ensure_from_paintmode(scene, paint_mode);
@@ -279,7 +279,7 @@ void WM_toolsystem_reinit_all(struct bContext *C, wmWindow *win)
{
bScreen *screen = WM_window_get_active_screen(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (((1 << area->spacetype) & WM_TOOLSYSTEM_SPACE_MASK) == 0) {
continue;
}
@@ -372,7 +372,7 @@ void WM_toolsystem_ref_sync_from_context(Main *bmain, WorkSpace *workspace, bToo
return;
}
wmWindowManager *wm = bmain->wm.first;
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (workspace != WM_window_get_active_workspace(win)) {
continue;
}
@@ -514,13 +514,13 @@ void WM_toolsystem_refresh_active(bContext *C)
{
Main *bmain = CTX_data_main(C);
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WorkSpace *workspace = WM_window_get_active_workspace(win);
bScreen *screen = WM_window_get_active_screen(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
/* Could skip loop for modes that don't depend on space type. */
int space_type_mask_handled = 0;
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
/* Don't change the space type of the active tool, only update it's mode. */
const int space_type_mask = (1 << area->spacetype);
if ((space_type_mask & WM_TOOLSYSTEM_SPACE_MASK) &&
@@ -547,7 +547,7 @@ void WM_toolsystem_refresh_active(bContext *C)
/* Refresh to ensure data is initialized.
* This is needed because undo can load a state which no longer has the underlying DNA data
* needed for the tool (un-initialized paint-slots for eg), see: T64339. */
- for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
toolsystem_refresh_ref(C, workspace, tref);
}
}
@@ -559,7 +559,7 @@ void WM_toolsystem_refresh_screen_area(WorkSpace *workspace, ViewLayer *view_lay
area->runtime.tool = NULL;
area->runtime.is_tool_set = true;
const int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype);
- for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
if (tref->space_type == area->spacetype) {
if (tref->mode == mode) {
area->runtime.tool = tref;
@@ -573,15 +573,15 @@ void WM_toolsystem_refresh_screen_all(Main *bmain)
{
/* Update all ScrArea's tools */
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
WorkSpace *workspace = WM_window_get_active_workspace(win);
bool space_type_has_tools[SPACE_TYPE_LAST + 1] = {0};
- for (bToolRef *tref = workspace->tools.first; tref; tref = tref->next) {
+ LISTBASE_FOREACH (bToolRef *, tref, &workspace->tools) {
space_type_has_tools[tref->space_type] = true;
}
bScreen *screen = WM_window_get_active_screen(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
area->runtime.tool = NULL;
area->runtime.is_tool_set = true;
if (space_type_has_tools[area->spacetype]) {
@@ -598,11 +598,11 @@ static void toolsystem_refresh_screen_from_active_tool(Main *bmain,
{
/* Update all ScrArea's tools */
for (wmWindowManager *wm = bmain->wm.first; wm; wm = wm->id.next) {
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (workspace == WM_window_get_active_workspace(win)) {
bScreen *screen = WM_window_get_active_screen(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
- for (ScrArea *area = screen->areabase.first; area; area = area->next) {
+ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
if (area->spacetype == tref->space_type) {
int mode = WM_toolsystem_mode_from_spacetype(view_layer, area, area->spacetype);
if (mode == tref->mode) {
@@ -761,7 +761,7 @@ void WM_toolsystem_update_from_context_view3d(bContext *C)
ScrArea *area_prev = CTX_wm_area(C);
ARegion *region_prev = CTX_wm_region(C);
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (win != win_prev) {
WorkSpace *workspace_iter = WM_window_get_active_workspace(win);
if (workspace_iter != workspace) {
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 694b3176f50..699f618f956 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -430,7 +430,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win)
/* Close child windows and bring windows back to front that dialogs have pushed behind the main
* window. */
- for (wmWindow *iter_win = wm->windows.first; iter_win; iter_win = iter_win->next) {
+ LISTBASE_FOREACH (wmWindow *, iter_win, &wm->windows) {
if (iter_win->parent == win) {
wm_window_close(C, wm, iter_win);
}
@@ -781,7 +781,7 @@ void wm_window_ghostwindows_ensure(wmWindowManager *wm)
#endif
}
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
wm_window_ghostwindow_ensure(wm, win, false);
}
}
@@ -2169,8 +2169,7 @@ void WM_window_screen_rect_calc(const wmWindow *win, rcti *r_rect)
screen_rect = window_rect;
/* Subtract global areas from screen rectangle. */
- for (ScrArea *global_area = win->global_areas.areabase.first; global_area;
- global_area = global_area->next) {
+ LISTBASE_FOREACH (ScrArea *, global_area, &win->global_areas.areabase) {
int height = ED_area_global_size_y(global_area) - 1;
if (global_area->global->flag & GLOBAL_AREA_IS_HIDDEN) {
@@ -2218,7 +2217,7 @@ bool WM_window_is_maximized(const wmWindow *win)
*/
void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene)
{
- for (wmWindow *win = win_lb->first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, win_lb) {
if (WM_window_get_active_scene(win) == scene) {
ED_workspace_scene_data_sync(win->workspace_hook, scene);
}
@@ -2227,7 +2226,7 @@ void WM_windows_scene_data_sync(const ListBase *win_lb, Scene *scene)
Scene *WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen *screen)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (WM_window_get_active_screen(win) == screen) {
return WM_window_get_active_scene(win);
}
@@ -2238,7 +2237,7 @@ Scene *WM_windows_scene_get_from_screen(const wmWindowManager *wm, const bScreen
WorkSpace *WM_windows_workspace_get_from_screen(const wmWindowManager *wm, const bScreen *screen)
{
- for (wmWindow *win = wm->windows.first; win; win = win->next) {
+ LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
if (WM_window_get_active_screen(win) == screen) {
return WM_window_get_active_workspace(win);
}
@@ -2266,7 +2265,7 @@ void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *
changed = true;
}
- for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
+ LISTBASE_FOREACH (wmWindow *, win_child, &wm->windows) {
if (win_child->parent == win_parent && win_child->scene != scene) {
ED_screen_scene_change(C, win_child, scene);
changed = true;
@@ -2312,7 +2311,7 @@ void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
wmWindow *win_parent = (win->parent) ? win->parent : win;
/* Set view layer in parent and child windows. */
- for (wmWindow *win_iter = wm->windows.first; win_iter; win_iter = win_iter->next) {
+ LISTBASE_FOREACH (wmWindow *, win_iter, &wm->windows) {
if ((win_iter == win_parent) || (win_iter->parent == win_parent)) {
STRNCPY(win_iter->view_layer_name, view_layer->name);
bScreen *screen = BKE_workspace_active_screen_get(win_iter->workspace_hook);
@@ -2344,7 +2343,7 @@ void WM_window_set_active_workspace(bContext *C, wmWindow *win, WorkSpace *works
ED_workspace_change(workspace, C, wm, win);
- for (wmWindow *win_child = wm->windows.first; win_child; win_child = win_child->next) {
+ LISTBASE_FOREACH (wmWindow *, win_child, &wm->windows) {
if (win_child->parent == win_parent) {
bScreen *screen = WM_window_get_active_screen(win_child);
/* Don't change temporary screens, they only serve a single purpose. */
diff --git a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c
index fd5237a70a5..86a106462c3 100644
--- a/source/blender/windowmanager/message_bus/intern/wm_message_bus.c
+++ b/source/blender/windowmanager/message_bus/intern/wm_message_bus.c
@@ -111,7 +111,7 @@ void WM_msgbus_clear_by_owner(struct wmMsgBus *mbus, void *owner)
void WM_msg_dump(struct wmMsgBus *mbus, const char *info_str)
{
printf(">>>> %s\n", info_str);
- for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) {
+ LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) {
const wmMsg *msg = wm_msg_subscribe_value_msg_cast(key);
const wmMsgTypeInfo *info = &wm_msg_types[msg->type];
info->repr(stdout, key);
@@ -131,8 +131,8 @@ void WM_msgbus_handle(struct wmMsgBus *mbus, struct bContext *C)
}
// uint a = 0, b = 0;
- for (wmMsgSubscribeKey *key = mbus->messages.first; key; key = key->next) {
- for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) {
+ LISTBASE_FOREACH (wmMsgSubscribeKey *, key, &mbus->messages) {
+ LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) {
if (msg_lnk->params.tag) {
msg_lnk->params.notify(C, key, &msg_lnk->params);
msg_lnk->params.tag = false;
@@ -175,7 +175,7 @@ wmMsgSubscribeKey *WM_msg_subscribe_with_key(struct wmMsgBus *mbus,
}
else {
key = *r_key;
- for (wmMsgSubscribeValueLink *msg_lnk = key->values.first; msg_lnk; msg_lnk = msg_lnk->next) {
+ LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &key->values) {
if ((msg_lnk->params.notify == msg_val_params->notify) &&
(msg_lnk->params.owner == msg_val_params->owner) &&
(msg_lnk->params.user_data == msg_val_params->user_data)) {
@@ -198,8 +198,7 @@ void WM_msg_publish_with_key(struct wmMsgBus *mbus, wmMsgSubscribeKey *msg_key)
msg_key,
BLI_listbase_count(&msg_key->values));
- for (wmMsgSubscribeValueLink *msg_lnk = msg_key->values.first; msg_lnk;
- msg_lnk = msg_lnk->next) {
+ LISTBASE_FOREACH (wmMsgSubscribeValueLink *, msg_lnk, &msg_key->values) {
if (false) { /* make an option? */
msg_lnk->params.notify(NULL, msg_key, &msg_lnk->params);
}