diff options
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 134 | ||||
-rw-r--r-- | source/blender/blenloader/intern/undofile.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 40 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 324 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_cycles.c | 48 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_defaults.c | 34 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_userdef.c | 10 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 102 |
8 files changed, 342 insertions, 352 deletions
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(®ion->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, ®ion->panels); - for (PanelCategoryStack *pc_act = region->panels_category_active.first; pc_act; - pc_act = pc_act->next) { + LISTBASE_FOREACH (PanelCategoryStack *, pc_act, ®ion->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, ®ion->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, ®ion->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); } |