From db4a46bc3c97bf9762a472bb8dcd4213b69acf83 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 21 Jun 2016 16:19:08 +0200 Subject: [PATCH] Cleanup: hide debug print behind proper debug defines instead of using comments... --- .../blender/blenloader/intern/readblenentry.c | 4 +-- source/blender/blenloader/intern/readfile.c | 28 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index b5ba9879057..be893177b3b 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -423,11 +423,11 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil BLI_remlink(&old_mainlist, libmain); BLI_addtail(&new_mainlist, libmain); } -#if 0 else { +#ifdef PRINT_DEBUG printf("Dropped Main for lib: %s\n", libmain->curlib->id.name); - } #endif + } } /* In any case, we need to move all lib datablocks themselves - those are 'first level data', * getting rid of them would imply updating spaces & co to prevent invalid pointers access. */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 838179ec0a9..6aa2fc4ac8c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7949,16 +7949,22 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short if (fd->memfile && ELEM(bhead->code, ID_LI, ID_ID)) { const char *idname = bhead_id_name(fd, bhead); - /* printf("Checking %s...\n", idname); */ +#ifdef PRINT_DEBUG + printf("Checking %s...\n", idname); +#endif if (bhead->code == ID_LI) { Main *libmain = fd->old_mainlist->first; /* Skip oldmain itself... */ for (libmain = libmain->next; libmain; libmain = libmain->next) { - /* printf("... against %s: ", libmain->curlib ? libmain->curlib->id.name : ""); */ +#ifdef PRINT_DEBUG + printf("... against %s: ", libmain->curlib ? libmain->curlib->id.name : ""); +#endif if (libmain->curlib && STREQ(idname, libmain->curlib->id.name)) { Main *oldmain = fd->old_mainlist->first; - /* printf("FOUND!\n"); */ +#ifdef PRINT_DEBUG + printf("FOUND!\n"); +#endif /* In case of a library, we need to re-add its main to fd->mainlist, because if we have later * a missing ID_ID, we need to get the correct lib it is linked to! * Order is crucial, we cannot bulk-add it in BLO_read_from_memfile() like it used to be... */ @@ -7972,13 +7978,19 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short } return blo_nextbhead(fd, bhead); } - /* printf("nothing...\n"); */ +#ifdef PRINT_DEBUG + printf("nothing...\n"); +#endif } } else { - /* printf("... in %s (%s): ", main->curlib ? main->curlib->id.name : "", main->curlib ? main->curlib->name : ""); */ +#ifdef PRINT_DEBUG + printf("... in %s (%s): ", main->curlib ? main->curlib->id.name : "", main->curlib ? main->curlib->name : ""); +#endif if ((id = BKE_libblock_find_name_ex(main, GS(idname), idname + 2))) { - /* printf("FOUND!\n"); */ +#ifdef PRINT_DEBUG + printf("FOUND!\n"); +#endif /* Even though we found our linked ID, there is no guarantee its address is still the same... */ if (id != bhead->old) { oldnewmap_insert(fd->libmap, bhead->old, id, GS(id->name)); @@ -7990,7 +8002,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short } return blo_nextbhead(fd, bhead); } - /* printf("nothing...\n"); */ +#ifdef PRINT_DEBUG + printf("nothing...\n"); +#endif } }