[Bf-blender-cvs] [76689e85170] master: Cleanup: use LISTBASE_FOREACH in readfile.c
Jacques Lucke
noreply at git.blender.org
Fri Aug 21 14:41:55 CEST 2020
Commit: 76689e85170027fa9fe2d6160b1a0921ccee6475
Author: Jacques Lucke
Date: Fri Aug 21 14:39:18 2020 +0200
Branches: master
https://developer.blender.org/rB76689e85170027fa9fe2d6160b1a0921ccee6475
Cleanup: use LISTBASE_FOREACH in readfile.c
===================================================================
M source/blender/blenloader/intern/readfile.c
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8b4b526472c..35e504f87b0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -1826,9 +1826,7 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
void *old,
void *new)
{
- Main *mainptr;
-
- for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) {
+ LISTBASE_FOREACH (Main *, mainptr, mainlist) {
FileData *fd;
if (mainptr->curlib) {
@@ -1852,9 +1850,7 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
*/
void blo_clear_proxy_pointers_from_lib(Main *oldmain)
{
- Object *ob = oldmain->objects.first;
-
- for (; ob; ob = ob->id.next) {
+ LISTBASE_FOREACH (Object *, ob, &oldmain->objects) {
if (ob->id.lib != NULL && ob->proxy_from != NULL && ob->proxy_from->id.lib == NULL) {
ob->proxy_from = NULL;
}
@@ -1872,47 +1868,39 @@ static void insert_packedmap(FileData *fd, PackedFile *pf)
void blo_make_packed_pointer_map(FileData *fd, Main *oldmain)
{
- Image *ima;
- VFont *vfont;
- bSound *sound;
- Volume *volume;
- Library *lib;
-
fd->packedmap = oldnewmap_new();
- for (ima = oldmain->images.first; ima; ima = ima->id.next) {
- ImagePackedFile *imapf;
-
+ LISTBASE_FOREACH (Image *, ima, &oldmain->images) {
if (ima->packedfile) {
insert_packedmap(fd, ima->packedfile);
}
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
if (imapf->packedfile) {
insert_packedmap(fd, imapf->packedfile);
}
}
}
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next) {
+ LISTBASE_FOREACH (VFont *, vfont, &oldmain->fonts) {
if (vfont->packedfile) {
insert_packedmap(fd, vfont->packedfile);
}
}
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next) {
+ LISTBASE_FOREACH (bSound *, sound, &oldmain->sounds) {
if (sound->packedfile) {
insert_packedmap(fd, sound->packedfile);
}
}
- for (volume = oldmain->volumes.first; volume; volume = volume->id.next) {
+ LISTBASE_FOREACH (Volume *, volume, &oldmain->volumes) {
if (volume->packedfile) {
insert_packedmap(fd, volume->packedfile);
}
}
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next) {
+ LISTBASE_FOREACH (Library *, lib, &oldmain->libraries) {
if (lib->packedfile) {
insert_packedmap(fd, lib->packedfile);
}
@@ -1923,44 +1911,36 @@ void blo_make_packed_pointer_map(FileData *fd, Main *oldmain)
/* this works because freeing old main only happens after this call */
void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
{
- Image *ima;
- VFont *vfont;
- bSound *sound;
- Volume *volume;
- Library *lib;
OldNew *entry = fd->packedmap->entries;
- int i;
/* used entries were restored, so we put them to zero */
- for (i = 0; i < fd->packedmap->nentries; i++, entry++) {
+ for (int i = 0; i < fd->packedmap->nentries; i++, entry++) {
if (entry->nr > 0) {
entry->newp = NULL;
}
}
- for (ima = oldmain->images.first; ima; ima = ima->id.next) {
- ImagePackedFile *imapf;
-
+ LISTBASE_FOREACH (Image *, ima, &oldmain->images) {
ima->packedfile = newpackedadr(fd, ima->packedfile);
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
+ LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
imapf->packedfile = newpackedadr(fd, imapf->packedfile);
}
}
- for (vfont = oldmain->fonts.first; vfont; vfont = vfont->id.next) {
+ LISTBASE_FOREACH (VFont *, vfont, &oldmain->fonts) {
vfont->packedfile = newpackedadr(fd, vfont->packedfile);
}
- for (sound = oldmain->sounds.first; sound; sound = sound->id.next) {
+ LISTBASE_FOREACH (bSound *, sound, &oldmain->sounds) {
sound->packedfile = newpackedadr(fd, sound->packedfile);
}
- for (lib = oldmain->libraries.first; lib; lib = lib->id.next) {
+ LISTBASE_FOREACH (Library *, lib, &oldmain->libraries) {
lib->packedfile = newpackedadr(fd, lib->packedfile);
}
- for (volume = oldmain->volumes.first; volume; volume = volume->id.next) {
+ LISTBASE_FOREACH (Volume *, volume, &oldmain->volumes) {
volume->packedfile = newpackedadr(fd, volume->packedfile);
}
}
@@ -1968,14 +1948,12 @@ void blo_end_packed_pointer_map(FileData *fd, Main *oldmain)
/* undo file support: add all library pointers in lookup */
void blo_add_library_pointer_map(ListBase *old_mainlist, FileData *fd)
{
- Main *ptr = old_mainlist->first;
ListBase *lbarray[MAX_LIBARRAY];
- for (ptr = ptr->next; ptr; ptr = ptr->next) {
+ LISTBASE_FOREACH (Main *, ptr, old_mainlist) {
int i = set_listbasepointers(ptr, lbarray);
while (i--) {
- ID *id;
- for (id = lbarray[i]->first; id; id = id->next) {
+ LISTBASE_FOREACH (ID *, id, lbarray[i]) {
oldnewmap_insert(fd->libmap, id, id, GS(id->name));
}
}
@@ -2277,8 +2255,7 @@ static PreviewImage *direct_link_preview_image(BlendDataReader *reader, PreviewI
PreviewImage *prv = BLO_read_get_new_data_address(reader, old_prv);
if (prv) {
- int i;
- for (i = 0; i < NUM_ICON_SIZES; i++) {
+ for (int i = 0; i < NUM_ICON_SIZES; i++) {
if (prv->rect[i]) {
BLO_read_data_address(reader, &prv->rect[i]);
}
@@ -2692,11 +2669,9 @@ static void lib_link_ipo(BlendLibReader *reader, Ipo *ipo)
// XXX deprecated - old animation system
static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
{
- IpoCurve *icu;
-
BLO_read_list(reader, &(ipo->curve));
- for (icu = ipo->curve.first; icu; icu = icu->next) {
+ LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
BLO_read_data_address(reader, &icu->bezt);
BLO_read_data_address(reader, &icu->bp);
BLO_read_data_address(reader, &icu->driver);
@@ -2706,14 +2681,11 @@ static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo)
// XXX deprecated - old animation system
static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist)
{
- bActionStrip *strip;
- bActionModifier *amod;
-
- for (strip = striplist->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (bActionStrip *, strip, striplist) {
BLO_read_id_address(reader, id->lib, &strip->object);
BLO_read_id_address(reader, id->lib, &strip->act);
BLO_read_id_address(reader, id->lib, &strip->ipo);
- for (amod = strip->modifiers.first; amod; amod = amod->next) {
+ LISTBASE_FOREACH (bActionModifier *, amod, &strip->modifiers) {
BLO_read_id_address(reader, id->lib, &amod->ob);
}
}
@@ -2722,11 +2694,9 @@ static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *stripli
// XXX deprecated - old animation system
static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
{
- bActionStrip *strip;
-
BLO_read_list(reader, strips);
- for (strip = strips->first; strip; strip = strip->next) {
+ LISTBASE_FOREACH (bActionStrip *, strip, strips) {
BLO_read_list(reader, &strip->modifiers);
}
}
@@ -2734,9 +2704,7 @@ static void direct_link_nlastrips(BlendDataReader *reader, ListBase *strips)
// XXX deprecated - old animation system
static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
{
- bConstraintChannel *chan;
-
- for (chan = chanbase->first; chan; chan = chan->next) {
+ LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
BLO_read_id_address(reader, id->lib, &chan->ipo);
}
}
@@ -2749,9 +2717,7 @@ static void lib_link_constraint_channels(BlendLibReader *reader, ID *id, ListBas
static void lib_link_fmodifiers(BlendLibReader *reader, ID *id, ListBase *list)
{
- FModifier *fcm;
-
- for (fcm = list->first; fcm; fcm = fcm->next) {
+ LISTBASE_FOREACH (FModifier *, fcm, list) {
/* data for specific modifiers */
switch (fcm->type) {
case FMODIFIER_TYPE_PYTHON: {
@@ -2766,20 +2732,16 @@ static void lib_link_fmodifiers(BlendLibReader *reader, ID *id, ListBase *list)
static void lib_link_fcurves(BlendLibReader *reader, ID *id, ListBase *list)
{
- FCurve *fcu;
-
if (list == NULL) {
return;
}
/* relink ID-block references... */
- for (fcu = list->first; fcu; fcu = fcu->next) {
+ LISTBASE_FOREACH (FCurve *, fcu, list) {
/* driver data */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
- DriverVar *dvar;
-
- for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
+ LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
DRIVER_TARGETS_LOOPER_BEGIN (dvar) {
/* only relink if still used */
if (tarIndex < dvar->num_targets) {
@@ -2801,9 +2763,7 @@ static void lib_link_fcurves(BlendLibReader *reader, ID *id, ListBase *list)
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_fmodifiers(BlendDataReader *reader, ListBase *list, FCurve *curve)
{
- FModifier *fcm;
-
- for (fcm = list->first; fcm; fcm = fcm->next) {
+ LISTBASE_FOREACH (FModifier *, fcm, list) {
/* relink general data */
BLO_read_data_address(reader, &fcm->data);
fcm->curve = curve;
@@ -2837,10 +2797,8 @@ static void direct_link_fmodifiers(BlendDataReader *reader, ListBase *list, FCur
/* NOTE: this assumes that link_list has already been called on the list */
static void direct_link_fcurves(BlendDataReader *reader, ListBase *list)
{
- FCurve *fcu;
-
/* link F-Curve data to F-Curve again (non ID-libs) */
- for (fcu = list->first; fcu; fcu = fcu->next) {
+ LISTBASE_FOREACH (FCurve *, fcu, list) {
/* curve data */
BLO_read_data_address(reader, &fcu->bezt);
BLO_read_data_address(reader, &fcu->fpt);
@@ -2860,7 +2818,6 @@ static void direct_link_fcurves(BlendDataReader *reader, ListBase *list)
BLO_read_data_address(reader, &fcu->driver);
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
- Driver
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list