From faabf92a7e891b355faf8ba6e2e2461e94262aab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Apr 2019 01:10:29 +1000 Subject: Cleanup: comments (long lines) in blenloader --- source/blender/blenloader/BLO_blend_validate.h | 3 +- source/blender/blenloader/intern/blend_validate.c | 8 +- source/blender/blenloader/intern/readblenentry.c | 33 +++-- source/blender/blenloader/intern/readfile.c | 141 ++++++++++++++------- source/blender/blenloader/intern/undofile.c | 6 +- source/blender/blenloader/intern/versioning_250.c | 35 +++-- source/blender/blenloader/intern/versioning_260.c | 28 ++-- source/blender/blenloader/intern/versioning_270.c | 10 +- source/blender/blenloader/intern/versioning_280.c | 34 +++-- .../blenloader/intern/versioning_defaults.c | 6 +- .../blender/blenloader/intern/versioning_legacy.c | 3 +- source/blender/blenloader/intern/writefile.c | 21 +-- 12 files changed, 210 insertions(+), 118 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenloader/BLO_blend_validate.h b/source/blender/blenloader/BLO_blend_validate.h index c0c2ceabb7f..1ffaddef02f 100644 --- a/source/blender/blenloader/BLO_blend_validate.h +++ b/source/blender/blenloader/BLO_blend_validate.h @@ -22,7 +22,8 @@ /** \file * \ingroup blenloader - * \brief Utils ensuring .blend file (i.e. Main) is in valid state during write and/or read process. + * \brief Utils ensuring .blend file (i.e. Main) + * is in valid state during write and/or read process. */ struct Main; diff --git a/source/blender/blenloader/intern/blend_validate.c b/source/blender/blenloader/intern/blend_validate.c index a71fe9f1adb..323ecedb971 100644 --- a/source/blender/blenloader/intern/blend_validate.c +++ b/source/blender/blenloader/intern/blend_validate.c @@ -17,7 +17,8 @@ /** \file * \ingroup blenloader * - * Utils to check/validate a Main is in sane state, only checks relations between datablocks and libraries for now. + * Utils to check/validate a Main is in sane state, + * only checks relations between datablocks and libraries for now. * * \note Does not *fix* anything, only reports found errors. */ @@ -45,7 +46,10 @@ #include "readfile.h" -/** Check (but do *not* fix) that all linked data-blocks are still valid (i.e. pointing to the right library). */ +/** + * Check (but do *not* fix) that all linked data-blocks are still valid + * (i.e. pointing to the right library). + */ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports) { ListBase mainlist; diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 6441c6d7a39..8067a322490 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -128,7 +128,8 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) } /** - * Gets the names of all the datablocks in a file of a certain type (e.g. all the scene names in a file). + * Gets the names of all the datablocks in a file of a certain type + * (e.g. all the scene names in a file). * * \param bh: The blendhandle to access. * \param ofblocktype: The type of names to get. @@ -158,7 +159,8 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, } /** - * Gets the previews of all the datablocks in a file of a certain type (e.g. all the scene previews in a file). + * Gets the previews of all the datablocks in a file of a certain type + * (e.g. all the scene previews in a file). * * \param bh: The blendhandle to access. * \param ofblocktype: The type of names to get. @@ -247,7 +249,8 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to } /** - * Gets the names of all the linkable datablock types available in a file. (e.g. "Scene", "Mesh", "Light", etc.). + * Gets the names of all the linkable datablock types available in a file. + * (e.g. "Scene", "Mesh", "Light", etc.). * * \param bh: The blendhandle to access. * \return A BLI_linklist of strings. The string links should be freed with malloc. @@ -348,9 +351,11 @@ BlendFileData *BLO_read_from_memory(const void *mem, } /** - * Used for undo/redo, skips part of libraries reading (assuming their data are already loaded & valid). + * Used for undo/redo, skips part of libraries reading + * (assuming their data are already loaded & valid). * - * \param oldmain: old main, from which we will keep libraries and other datablocks that should not have changed. + * \param oldmain: old main, + * from which we will keep libraries and other datablocks that should not have changed. * \param filename: current file, only for retrieving library data. */ BlendFileData *BLO_read_from_memfile(Main *oldmain, @@ -410,17 +415,18 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, BLI_assert(old_mainlist.first == oldmain); if (bfd && old_mainlist.first != old_mainlist.last) { - /* Even though directly used libs have been already moved to new main, indirect ones have not. - * This is a bit annoying, but we have no choice but to keep them all for now - means some now unused - * data may remain in memory, but think we'll have to live with it. */ + /* Even though directly used libs have been already moved to new main, + * indirect ones have not. + * This is a bit annoying, but we have no choice but to keep them all for now - + * means some now unused data may remain in memory, but think we'll have to live with it. */ Main *libmain, *libmain_next; Main *newmain = bfd->main; ListBase new_mainlist = {newmain, newmain}; for (libmain = oldmain->next; libmain; libmain = libmain_next) { libmain_next = libmain->next; - /* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL parent - * to detect indirect-linked ones... */ + /* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL + * parent to detect indirect-linked ones. */ if (libmain->curlib && (libmain->curlib->parent != NULL)) { BLI_remlink(&old_mainlist, libmain); BLI_addtail(&new_mainlist, libmain); @@ -438,7 +444,9 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, blo_join_main(&new_mainlist); } - /* printf("Remaining mains/libs in oldmain: %d\n", BLI_listbase_count(&fd->old_mainlist) - 1); */ +#if 0 + printf("Remaining mains/libs in oldmain: %d\n", BLI_listbase_count(&fd->old_mainlist) - 1); +#endif /* That way, libs (aka mains) we did not reuse in new undone/redone state * will be cleared together with oldmain... */ @@ -451,7 +459,8 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, } /** - * Frees a BlendFileData structure and *all* the data associated with it (the userdef data, and the main libblock data). + * Frees a BlendFileData structure and *all* the data associated with it + * (the userdef data, and the main libblock data). * * \param bfd: The structure to free. */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 2708ad4fa3e..706f28eb312 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -571,7 +571,8 @@ void blo_split_main(ListBase *mainlist, Main *main) while (i--) { ID *id = lbarray[i]->first; if (id == NULL || GS(id->name) == ID_LI) { - continue; /* no ID_LI datablock should ever be linked anyway, but just in case, better be explicit. */ + /* No ID_LI datablock should ever be linked anyway, but just in case, better be explicit. */ + continue; } split_libdata(lbarray[i], lib_main_array, lib_main_array_len); } @@ -1379,8 +1380,8 @@ FileData *blo_filedata_from_file(const char *filepath, ReportList *reports) } /** - * Same as blo_filedata_from_file(), but does not reads DNA data, only header. Use it for light access - * (e.g. thumbnail reading). + * Same as blo_filedata_from_file(), but does not reads DNA data, only header. + * Use it for light access (e.g. thumbnail reading). */ static FileData *blo_filedata_from_file_minimal(const char *filepath) { @@ -1582,7 +1583,8 @@ bool BLO_has_bfile_extension(const char *str) */ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name) { - /* We might get some data names with slashes, so we have to go up in path until we find blend file itself, + /* We might get some data names with slashes, + * so we have to go up in path until we find blend file itself, * then we now next path item is group, and everything else is data name. */ char *slash = NULL, *prev_slash = NULL, c = '\0'; @@ -1644,7 +1646,8 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha * * \param filepath: The path of the file to extract thumbnail from. * \return The raw thumbnail - * (MEM-allocated, as stored in file, use #BKE_main_thumbnail_to_imbuf() to convert it to ImBuf image). + * (MEM-allocated, as stored in file, use #BKE_main_thumbnail_to_imbuf() + * to convert it to ImBuf image). */ BlendThumbnail *BLO_thumbnail_from_file(const char *filepath) { @@ -2034,7 +2037,8 @@ void blo_end_sound_pointer_map(FileData *fd, Main *oldmain) } } -/* XXX disabled this feature - packed files also belong in temp saves and quit.blend, to make restore work */ +/* XXX disabled this feature - packed files also belong in temp saves and quit.blend, + * to make restore work. */ static void insert_packedmap(FileData *fd, PackedFile *pf) { @@ -2584,7 +2588,8 @@ static void direct_link_id(FileData *fd, ID *id) } id->py_instance = NULL; - /* That way datablock reading not going through main read_libblock() function are still in a clear tag state. + /* That way datablock reading not going through main read_libblock() + * function are still in a clear tag state. * (glowering at certain nodetree fake datablock here...). */ id->tag = 0; @@ -2955,7 +2960,8 @@ static void direct_link_fcurves(FileData *fd, ListBase *list) ChannelDriver *driver = fcu->driver; DriverVar *dvar; - /* compiled expression data will need to be regenerated (old pointer may still be set here) */ + /* Compiled expression data will need to be regenerated + * (old pointer may still be set here). */ driver->expr_comp = NULL; driver->expr_simple = NULL; @@ -5900,7 +5906,8 @@ static void direct_link_object(FileData *fd, Object *ob) { PartEff *paf; - /* XXX This should not be needed - but seems like it can happen in some cases, so for now play safe... */ + /* XXX This should not be needed - but seems like it can happen in some cases, + * so for now play safe. */ ob->proxy_from = NULL; /* loading saved files with editmode enabled works, but for undo we like @@ -6847,7 +6854,8 @@ static void direct_link_scene(FileData *fd, Scene *sce) } SEQ_END; - /* link metastack, slight abuse of structs here, have to restore pointer to internal part in struct */ + /* link metastack, slight abuse of structs here, + * have to restore pointer to internal part in struct */ { Sequence temp; void *poin; @@ -7647,7 +7655,8 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm) WorkSpaceInstanceHook *hook = win->workspace_hook; win->workspace_hook = newdataadr(fd, hook); - /* we need to restore a pointer to this later when reading workspaces, so store in global oldnew-map */ + /* we need to restore a pointer to this later when reading workspaces, + * so store in global oldnew-map. */ oldnewmap_insert(fd->globmap, hook, win->workspace_hook, 0); direct_link_area_map(fd, &win->global_areas); @@ -7877,7 +7886,8 @@ static void lib_link_window_scene_data_restore(wmWindow *win, Scene *scene, View v3d->localvd->camera = scene->camera; - /* Localview can become invalid during undo/redo steps, so we exit it when no could be found. */ + /* Localview can become invalid during undo/redo steps, + * so we exit it when no could be found. */ for (base = view_layer->object_bases.first; base; base = base->next) { if (base->local_view_bits & v3d->local_view_uuid) { break; @@ -8248,8 +8258,9 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) BLI_remlink(&main->libraries, lib); MEM_freeN(lib); - /* Now, since Blender always expect **latest** Main pointer from fd->mainlist to be the active library - * Main pointer, where to add all non-library data-blocks found in file next, we have to switch that + /* Now, since Blender always expect **latest** Main pointer from fd->mainlist + * to be the active library Main pointer, + * where to add all non-library data-blocks found in file next, we have to switch that * 'dupli' found Main to latest position in the list! * Otherwise, you get weird disappearing linked data on a rather inconsistent basis. * See also T53977 for reproducible case. */ @@ -8286,7 +8297,8 @@ static void lib_link_library(FileData *UNUSED(fd), Main *main) } } -/* Always call this once you have loaded new library data to set the relative paths correctly in relation to the blend file */ +/* Always call this once you have loaded new library data to set the relative paths correctly + * in relation to the blend file. */ static void fix_relpaths_library(const char *basepath, Main *main) { Library *lib; @@ -8306,7 +8318,8 @@ static void fix_relpaths_library(const char *basepath, Main *main) else { for (lib = main->libraries.first; lib; lib = lib->id.next) { /* Libraries store both relative and abs paths, recreate relative paths, - * relative to the blend file since indirectly linked libs will be relative to their direct linked library */ + * relative to the blend file since indirectly linked libs will be + * relative to their direct linked library. */ if (BLI_path_is_rel(lib->name)) { /* if this is relative to begin with? */ BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name)); BLI_path_rel(lib->name, basepath); @@ -9031,11 +9044,14 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta const char *allocname; bool wrong_id = false; - /* In undo case, most libs and linked data should be kept as is from previous state (see BLO_read_from_memfile). - * However, some needed by the snapshot being read may have been removed in previous one, and would go missing. + /* In undo case, most libs and linked data should be kept as is from previous state + * (see BLO_read_from_memfile). + * However, some needed by the snapshot being read may have been removed in previous one, + * and would go missing. * This leads e.g. to disappearing objects in some undo/redo case, see T34446. - * That means we have to carefully check whether current lib or libdata already exits in old main, if it does - * we merely copy it over into new main area, otherwise we have to do a full read of that bhead... */ + * That means we have to carefully check whether current lib or + * libdata already exits in old main, if it does we merely copy it over into new main area, + * otherwise we have to do a full read of that bhead... */ if (fd->memfile && ELEM(bhead->code, ID_LI, ID_LINK_PLACEHOLDER)) { const char *idname = blo_bhead_id_name(fd, bhead); @@ -9049,9 +9065,11 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta if (libmain->curlib && STREQ(idname, libmain->curlib->id.name)) { Main *oldmain = fd->old_mainlist->first; DEBUG_PRINTF("FOUND!\n"); - /* In case of a library, we need to re-add its main to fd->mainlist, because if we have later - * a missing ID_LINK_PLACEHOLDER, 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... */ + /* In case of a library, we need to re-add its main to fd->mainlist, + * because if we have later a missing ID_LINK_PLACEHOLDER, + * 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. */ BLI_remlink(fd->old_mainlist, libmain); BLI_remlink_safe(&oldmain->libraries, libmain->curlib); BLI_addtail(fd->mainlist, libmain); @@ -9071,12 +9089,14 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const int ta main->curlib ? main->curlib->name : ""); if ((id = BKE_libblock_find_name(main, GS(idname), idname + 2))) { DEBUG_PRINTF("FOUND!\n"); - /* Even though we found our linked ID, there is no guarantee its address is still the same... */ + /* 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)); } - /* No need to do anything else for ID_LINK_PLACEHOLDER, it's assumed already present in its lib's main... */ + /* No need to do anything else for ID_LINK_PLACEHOLDER, + * it's assumed already present in its lib's main. */ if (r_id) { *r_id = NULL; /* Just in case... */ } @@ -9283,7 +9303,8 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->globalf = fg->globalf; BLI_strncpy(bfd->filename, fg->filename, sizeof(bfd->filename)); - /* error in 2.65 and older: main->name was not set if you save from startup (not after loading file) */ + /* Error in 2.65 and older: main->name was not set if you save from startup + * (not after loading file). */ if (bfd->filename[0] == 0) { if (fd->fileversion < 265 || (fd->fileversion == 265 && fg->subversion < 1)) if ((G.fileflags & G_FILE_RECOVER) == 0) @@ -9341,7 +9362,8 @@ static void do_versions_userdef(FileData *fd, BlendFileData *bfd) if (MAIN_VERSION_OLDER(bmain, 266, 4)) { bTheme *btheme; - /* themes for Node and Sequence editor were not using grid color, but back. we copy this over then */ + /* Themes for Node and Sequence editor were not using grid color, + * but back. we copy this over then. */ for (btheme = user->themes.first; btheme; btheme = btheme->next) { copy_v4_v4_char(btheme->space_node.grid, btheme->space_node.back); copy_v4_v4_char(btheme->space_sequencer.grid, btheme->space_sequencer.back); @@ -9426,7 +9448,8 @@ static void lib_link_all(FileData *fd, Main *main) if (fd->memfile == NULL) { lib_link_windowmanager(fd, main); } - /* DO NOT skip screens here, 3Dview may contains pointers to other ID data (like bgpic)! See T41411. */ + /* DO NOT skip screens here, + * 3D viewport may contains pointers to other ID data (like bgpic)! See T41411. */ lib_link_screen(fd, main); lib_link_scene(fd, main); lib_link_object(fd, main); @@ -9916,8 +9939,12 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) * read yet at that point. */ change_link_placeholder_to_real_ID_pointer_fd(fd, bhead->old, id); - // commented because this can print way too much - // if (G.debug & G_DEBUG) printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name); + /* Commented because this can print way too much. */ +#if 0 + if (G.debug & G_DEBUG) { + printf("expand_doit: already linked: %s lib: %s\n", id->name, lib->name); + } +#endif } MEM_freeN(lib); @@ -9934,8 +9961,9 @@ static void expand_doit_library(void *fdhandle, Main *mainvar, void *old) read_libblock(fd, mainvar, bhead, LIB_TAG_NEED_EXPAND | LIB_TAG_INDIRECT, NULL); } else { - /* this is actually only needed on UI call? when ID was already read before, and another append - * happens which invokes same ID... in that case the lookup table needs this entry */ + /* this is actually only needed on UI call? when ID was already read before, + * and another append happens which invokes same ID... + * in that case the lookup table needs this entry */ oldnewmap_insert(fd->libmap, bhead->old, id, bhead->code); // commented because this can print way too much // if (G.debug & G_DEBUG) printf("expand: already read %s\n", id->name); @@ -10944,7 +10972,8 @@ static void add_loose_objects_to_scene(Main *mainvar, BLI_assert(scene); - /* Give all objects which are LIB_TAG_INDIRECT a base, or for a collection when *lib has been set. */ + /* Give all objects which are LIB_TAG_INDIRECT a base, + * or for a collection when *lib has been set. */ for (Object *ob = mainvar->objects.first; ob; ob = ob->id.next) { bool do_it = (ob->id.tag & LIB_TAG_DOIT) != 0; if (do_it || ((ob->id.tag & LIB_TAG_INDIRECT) && (ob->id.tag & LIB_TAG_PRE_EXISTING) == 0)) { @@ -10953,7 +10982,8 @@ static void add_loose_objects_to_scene(Main *mainvar, do_it = true; } else if ((ob->id.lib == lib) && (object_in_any_scene(bmain, ob) == 0)) { - /* When appending, make sure any indirectly loaded objects get a base, else they cant be accessed at all + /* When appending, make sure any indirectly loaded objects get a base, + * else they cant be accessed at all * (see T27437). */ do_it = true; } @@ -10983,7 +11013,8 @@ static void add_loose_objects_to_scene(Main *mainvar, if (flag & FILE_AUTOSELECT) { base->flag |= BASE_SELECTED; - /* Do NOT make base active here! screws up GUI stuff, if you want it do it on src/ level. */ + /* Do NOT make base active here! screws up GUI stuff, + * if you want it do it on src/ level. */ } BKE_scene_object_base_flag_sync_from_base(base); @@ -11046,14 +11077,16 @@ static void add_collections_to_scene(Main *mainvar, /* We do not want to force instantiation of indirectly linked collections... * Except when we are appending (since in that case, we'll end up instantiating all objects, * it's better to do it via their own collections if possible). - * Reports showing that desired difference in behaviors between link and append: T62570, T61796. */ + * Reports showing that desired difference in behaviors between link and append: + * See T62570, T61796. */ else if (do_append || (collection->id.tag & LIB_TAG_INDIRECT) == 0) { bool do_add_collection = (collection->id.tag & LIB_TAG_DOIT) != 0; if (!do_add_collection) { /* We need to check that objects in that collections are already instantiated in a scene. * Otherwise, it's better to add the collection to the scene's active collection, than to * instantiate its objects in active scene's collection directly. See T61141. - * Note that we only check object directly into that collection, not recursively into its children. + * Note that we only check object directly into that collection, + * not recursively into its children. */ for (CollectionObject *coll_ob = collection->gobject.first; coll_ob != NULL; coll_ob = coll_ob->next) { @@ -11245,8 +11278,10 @@ ID *BLO_library_link_named_part(Main *mainl, * \param idcode: The kind of data-block to link. * \param name: The name of the data-block (without the 2 char ID prefix). * \param flag: Options for linking, used for instantiating. - * \param scene: The scene in which to instantiate objects/collections (if NULL, no instantiation is done). - * \param v3d: The active View3D (only to define active layers for instantiated objects & collections, can be NULL). + * \param scene: The scene in which to instantiate objects/collections + * (if NULL, no instantiation is done). + * \param v3d: The active 3D viewport. + * (only to define active layers for instantiated objects & collections, can be NULL). * \return the linked ID when found. */ ID *BLO_library_link_named_part_ex( @@ -11287,10 +11322,11 @@ static Main *library_link_begin(Main *mainvar, FileData **fd, const char *filepa /** * Initialize the BlendHandle for linking library data. * - * \param mainvar: The current main database, e.g. G_MAIN or CTX_data_main(C). - * \param bh: A blender file handle as returned by \a BLO_blendhandle_from_file or \a BLO_blendhandle_from_memory. + * \param mainvar: The current main database, e.g. #G_MAIN or #CTX_data_main(C). + * \param bh: A blender file handle as returned by + * #BLO_blendhandle_from_file or #BLO_blendhandle_from_memory. * \param filepath: Used for relative linking, copied to the \a lib->name. - * \return the library Main, to be passed to \a BLO_library_append_named_part as \a mainl. + * \return the library Main, to be passed to #BLO_library_append_named_part as \a mainl. */ Main *BLO_library_link_begin(Main *mainvar, BlendHandle **bh, const char *filepath) { @@ -11368,7 +11404,8 @@ static void library_link_end(Main *mainl, Main *main_newid = BKE_main_new(); for (mainvar = ((Main *)(*fd)->mainlist->first)->next; mainvar; mainvar = mainvar->next) { BLI_assert(mainvar->versionfile != 0); - /* We need to split out IDs already existing, or they will go again through do_versions - bad, very bad! */ + /* We need to split out IDs already existing, + * or they will go again through do_versions - bad, very bad! */ split_main_newid(mainvar, main_newid); do_versions_after_linking(main_newid); @@ -11387,7 +11424,8 @@ static void library_link_end(Main *mainl, mainvar); /* make all relative paths, relative to the open blend file */ /* Give a base to loose objects and collections. - * Only directly linked objects & collections are instantiated by `BLO_library_link_named_part_ex()` & co, + * Only directly linked objects & collections are instantiated by + * `BLO_library_link_named_part_ex()` & co, * here we handle indirect ones and other possible edge-cases. */ if (scene) { add_collections_to_scene(mainvar, bmain, scene, view_layer, v3d, curlib, flag); @@ -11417,9 +11455,12 @@ static void library_link_end(Main *mainl, * \param bh: The blender file handle (WARNING! may be freed by this function!). * \param flag: Options for linking, used for instantiating. * \param bmain: The main database in which to instantiate objects/collections - * \param scene: The scene in which to instantiate objects/collections (if NULL, no instantiation is done). - * \param view_layer: The scene layer in which to instantiate objects/collections (if NULL, no instantiation is done). - * \param v3d: The active View3D (only to define local-view for instantiated objects & groups, can be NULL). + * \param scene: The scene in which to instantiate objects/collections + * (if NULL, no instantiation is done). + * \param view_layer: The scene layer in which to instantiate objects/collections + * (if NULL, no instantiation is done). + * \param v3d: The active 3D viewport + * (only to define local-view for instantiated objects & groups, can be NULL). */ void BLO_library_link_end(Main *mainl, BlendHandle **bh, @@ -11656,7 +11697,11 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) for (Main *mainptr = mainl->next; mainptr; mainptr = mainptr->next) { /* Does this library have any more linked datablocks we need to read? */ if (has_linked_ids_to_read(mainptr)) { - // printf("Reading linked datablocks from %s (%s)\n", mainptr->curlib->id.name, mainptr->curlib->name); +#if 0 + printf("Reading linked datablocks from %s (%s)\n", + mainptr->curlib->id.name, + mainptr->curlib->name); +#endif /* Open file if it has not been done yet. */ FileData *fd = read_library_file_data(basefd, mainlist, mainl, mainptr); diff --git a/source/blender/blenloader/intern/undofile.c b/source/blender/blenloader/intern/undofile.c index 0c09aa34a8b..55103a98b9e 100644 --- a/source/blender/blenloader/intern/undofile.c +++ b/source/blender/blenloader/intern/undofile.c @@ -149,8 +149,10 @@ bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename) MemFileChunk *chunk; int file, oflags; - /* note: This is currently used for autosave and 'quit.blend', where _not_ following symlinks is OK, - * however if this is ever executed explicitly by the user, we may want to allow writing to symlinks. + /* note: This is currently used for autosave and 'quit.blend', + * where _not_ following symlinks is OK, + * however if this is ever executed explicitly by the user, + * we may want to allow writing to symlinks. */ oflags = O_BINARY | O_WRONLY | O_CREAT | O_TRUNC; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 723701da113..7873f0620c3 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -310,7 +310,8 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) case SPACE_ACTION: { SpaceAction *saction = (SpaceAction *)sl; - /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */ + /* We totally reinit the view for the Action Editor, + * as some old instances had some weird cruft set. */ ar->v2d.tot.xmin = -20.0f; ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)((sa->winx > 120) ? (sa->winx) : 120); @@ -577,9 +578,10 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup, } /* Create default_value structs for node sockets from the internal bNodeStack value. - * These structs were used from 2.59.2 on, but are replaced in the subsequent do_versions for custom nodes - * by generic ID property values. This conversion happened _after_ do_versions originally due to messy type initialization - * for node sockets. Now created here intermediately for convenience and to keep do_versions consistent. + * These structs were used from 2.59.2 on, but are replaced in the subsequent do_versions for + * custom nodes by generic ID property values. This conversion happened _after_ do_versions + * originally due to messy type initialization for node sockets. + * Now created here intermediately for convenience and to keep do_versions consistent. * * Node compatibility code is gross ... */ @@ -848,7 +850,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (fluidmd) fluidmd->fss->fmd = fluidmd; - /* rotation modes were added, but old objects would now default to being 'quaternion based' */ + /* rotation modes were added, + * but old objects would now default to being 'quaternion based' */ ob->rotmode = ROT_MODE_EUL; } @@ -874,7 +877,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } } - /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */ + /* Assign proper global gravity weights for dynamics + * (only z-coordinate is taken into account) */ if (do_gravity) { for (part = bmain->particles.first; part; part = part->id.next) part->effector_weights->global_gravity = part->acc[2] / -9.81f; @@ -914,7 +918,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 6)) { Object *ob; - /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */ + /* New variables for axis-angle rotations and/or quaternion rotations were added, + * and need proper initialization */ for (ob = bmain->objects.first; ob; ob = ob->id.next) { /* new variables for all objects */ ob->quat[0] = 1.0f; @@ -1898,7 +1903,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) copy_v4_v4(gsock->ns.vec, sock->ns.vec); /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer, - * have to create these directly here. These links are updated again in subsequent do_version! + * have to create these directly here. + * These links are updated again in subsequent do_version! */ link = MEM_callocN(sizeof(bNodeLink), "link"); BLI_addtail(&ntree->links, link); @@ -1920,7 +1926,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) copy_v4_v4(gsock->ns.vec, sock->ns.vec); /* XXX nodeAddLink does not work with incomplete (node==NULL) links any longer, - * have to create these directly here. These links are updated again in subsequent do_version! + * have to create these directly here. + * These links are updated again in subsequent do_version! */ link = MEM_callocN(sizeof(bNodeLink), "link"); BLI_addtail(&ntree->links, link); @@ -1954,7 +1961,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) for (sc = bmain->screens.first; sc; sc = sc->id.next) { if (sc->redraws_flag == 0) { /* just initialize to default? */ - /* XXX: we could also have iterated through areas, and taken them from the first timeline available... */ + /* XXX: we could also have iterated through areas, + * and taken them from the first timeline available... */ sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; } } @@ -2007,9 +2015,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) } if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) { - /* screen view2d settings were not properly initialized [#27164] - * v2d->scroll caused the bug but best reset other values too which are in old blend files only. - * need to make less ugly - possibly an iterator? */ + /* screen view2d settings were not properly initialized T27164. + * v2d->scroll caused the bug but best reset other values too + * which are in old blend files only. + * Need to make less ugly - possibly an iterator? */ bScreen *screen; for (screen = bmain->screens.first; screen; screen = screen->id.next) { diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 785e6b4016e..324b3db3038 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -106,7 +106,8 @@ static void do_versions_nodetree_convert_angle(bNodeTree *ntree) else if (node->type == CMP_NODE_DEFOCUS) { /* Convert degrees to radians. */ NodeDefocus *nqd = node->storage; - /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */ + /* XXX DNA char to float conversion seems to map the char value + * into the [0.0f, 1.0f] range. */ nqd->rotation = DEG2RADF(nqd->rotation * 255.0f); } else if (node->type == CMP_NODE_CHROMA_MATTE) { @@ -118,7 +119,8 @@ static void do_versions_nodetree_convert_angle(bNodeTree *ntree) else if (node->type == CMP_NODE_GLARE) { /* Convert degrees to radians. */ NodeGlare *ndg = node->storage; - /* XXX DNA char to float conversion seems to map the char value into the [0.0f, 1.0f] range... */ + /* XXX DNA char to float conversion seems to map the char value + * into the [0.0f, 1.0f] range. */ ndg->angle_ofs = DEG2RADF(ndg->angle_ofs * 255.0f); } /* XXX TexMapping struct is used by other nodes too (at least node_composite_mapValue), @@ -233,7 +235,8 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo bNodeSocket *sock; char filename[FILE_MAXFILE]; - /* ugly, need to remove the old inputs list to avoid bad pointer checks when adding new sockets. + /* ugly, need to remove the old inputs list to avoid bad pointer + * checks when adding new sockets. * sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket. */ BLI_listbase_clear(&node->inputs); @@ -457,7 +460,8 @@ static const char *node_get_static_idname(int type, int treetype) case ID: \ return #Category #StructName; - /* XXX hack, group types share a single static integer identifier, but are registered as separate types */ + /* XXX hack, group types share a single static integer identifier, + * but are registered as separate types */ if (type == NODE_GROUP) { switch (treetype) { case NTREE_COMPOSIT: @@ -1450,13 +1454,12 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) ima->flag |= IMA_VIEW_AS_RENDER; } else if (colormanagement_disabled) { - /* if colormanagement not used, set image's color space to raw, so no sRGB->linear conversion - * would happen on display and render - * there's no clear way to check whether color management is enabled or not in render engine - * so set all images to raw if there's at least one scene with color management disabled - * this would still behave incorrect in cases when color management was used for only some - * of scenes, but such a setup is crazy anyway and think it's fair enough to break compatibility - * in that cases + /* if color-management not used, set image's color space to raw, so no sRGB->linear + * conversion would happen on display and render there's no clear way to check whether + * color management is enabled or not in render engine so set all images to raw if there's + * at least one scene with color management disabled this would still behave incorrect in + * cases when color management was used for only some of scenes, but such a setup is + * crazy anyway and think it's fair enough to break compatibility in that cases. */ BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name)); @@ -1877,7 +1880,8 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) } } - /* Set flag for delayed do_versions in lib_verify_nodetree. It needs valid typeinfo pointers ... */ + /* Set flag for delayed do_versions in lib_verify_nodetree. + * It needs valid typeinfo pointers ... */ { FOREACH_NODETREE_BEGIN (bmain, ntree, id) { /* XXX This should be kept without version check for now! diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 69416f08205..3d2a46db769 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -508,7 +508,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 270, 4)) { - /* ui_previews were not handled correctly when copying areas, leading to corrupted files (see T39847). + /* ui_previews were not handled correctly when copying areas, + * leading to corrupted files (see T39847). * This will always reset situation to a valid state. */ bScreen *sc; @@ -1153,7 +1154,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) if (scene->gpd) { bGPdata *gpd = scene->gpd; - /* Copy over the settings stored in the GP datablock linked to the scene, for minimal disruption */ + /* Copy over the settings stored in the GP data-block linked to the scene, + * for minimal disruption. */ ts->gpencil_v3d_align = 0; if (gpd->flag & GP_DATA_VIEWALIGN) @@ -1201,8 +1203,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) ListBase *lbarray[MAX_LIBARRAY]; int a; - /* Important to clear all non-persistent flags from older versions here, otherwise they could collide - * with any new persistent flag we may add in the future. */ + /* Important to clear all non-persistent flags from older versions here, + * 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) { diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 5f13bea1c28..ceeeaf11e9d 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -98,7 +98,8 @@ 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) */ + /* 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 *sa = screen->areabase.first; sa; sa = sa->next) { if (sa->full && sa->full != screen) { @@ -173,7 +174,8 @@ static void do_version_area_change_space_to_space_action(ScrArea *area, const Sc * - Active scene isn't stored in screen anymore, but in window. * - Create workspace instance hook for each window. * - * \note Some of the created workspaces might be deleted again in case of reading the default startup.blend. + * \note Some of the created workspaces might be deleted again + * in case of reading the default `startup.blend`. */ static void do_version_workspaces_after_lib_link(Main *bmain) { @@ -187,7 +189,8 @@ static void do_version_workspaces_after_lib_link(Main *bmain) bScreen *screen = screen_parent ? screen_parent : win->screen; if (screen->temp) { - /* We do not generate a new workspace for those screens... still need to set some data in win. */ + /* We do not generate a new workspace for those screens... + * still need to set some data in win. */ win->workspace_hook = BKE_workspace_instance_hook_create(bmain); win->scene = screen->scene; /* Deprecated from now on! */ @@ -509,7 +512,8 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) if (have_override || need_default_renderlayer) { ViewLayer *view_layer = BKE_view_layer_add(scene, "Viewport"); - /* If we ported all the original render layers, we don't need to make the viewport layer renderable. */ + /* If we ported all the original render layers, + * we don't need to make the viewport layer renderable. */ if (!BLI_listbase_is_single(&scene->view_layers)) { view_layer->flag &= ~VIEW_LAYER_RENDER; } @@ -665,9 +669,11 @@ void do_versions_after_linking_280(Main *bmain) } } - /* We need to assign lib pointer to generated hidden collections *after* all have been created, otherwise we'll - * end up with several datablocks sharing same name/library, which is FORBIDDEN! - * Note: we need this to be recursive, since a child collection may be sorted before its parent in bmain... */ + /* We need to assign lib pointer to generated hidden collections *after* all have been created, + * otherwise we'll end up with several datablocks sharing same name/library, + * which is FORBIDDEN! + * Note: we need this to be recursive, + * since a child collection may be sorted before its parent in bmain. */ for (Collection *collection = bmain->collections.first; collection != NULL; collection = collection->id.next) { do_version_collection_propagate_lib_to_children(collection); @@ -758,8 +764,9 @@ void do_versions_after_linking_280(Main *bmain) } if (!MAIN_VERSION_ATLEAST(bmain, 280, 3)) { - /* Due to several changes to particle RNA and draw code particles from older files may no longer - * be visible. Here we correct this by setting a default draw size for those files. */ + /* Due to several changes to particle RNA and draw code particles from older files may + * 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) { if (psys->part->draw_size == 0.0f) { @@ -983,8 +990,10 @@ void do_versions_after_linking_280(Main *bmain) } } -/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already. - * But in 2.79 another case generating non-unique names was discovered (see T55668, involving Meta strips)... */ +/* NOTE: This version patch is intended for versions < 2.52.2, + * but was initially introduced in 2.27 already. + * But in 2.79 another case generating non-unique names was discovered + * (see T55668, involving Meta strips). */ static void do_versions_seq_unique_name_all_strips(Scene *sce, ListBase *seqbasep) { for (Sequence *seq = seqbasep->first; seq != NULL; seq = seq->next) { @@ -1811,7 +1820,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sl; - /* "Dopesheet" should be default here, unless it looks like the Action Editor was active instead */ + /* "Dopesheet" should be default here, + * unless it looks like the Action Editor was active instead. */ if ((saction->mode_prev == 0) && (saction->action == NULL)) { saction->mode_prev = SACTCONT_DOPESHEET; } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 6a72ff58f32..a89b9a034f0 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -92,7 +92,8 @@ void BLO_update_defaults_userpref_blend(void) /* Leave temp directory empty, will then get appropriate value per OS. */ U.tempdir[0] = '\0'; - /* Only enable tooltips translation by default, without actually enabling translation itself, for now. */ + /* Only enable tooltips translation by default, + * without actually enabling translation itself, for now. */ U.transopts = USER_TR_TOOLTIPS; U.memcachelimit = 4096; @@ -147,7 +148,8 @@ void BLO_update_defaults_startup_blend(Main *bmain, const char *app_template) for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { for (ARegion *ar = sa->regionbase.first; ar; ar = ar->next) { - /* Remove all stored panels, we want to use defaults (order, open/closed) as defined by UI code here! */ + /* Remove all stored panels, we want to use defaults + * (order, open/closed) as defined by UI code here! */ BKE_area_region_panels_free(&ar->panels); /* some toolbars have been saved as initialized, diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 7fea9dffece..2d181407811 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -456,7 +456,8 @@ PartEff *blo_do_version_give_parteff_245(Object *ob) return NULL; } -/* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */ +/* NOTE: this version patch is intended for versions < 2.52.2, + * but was initially introduced in 2.27 already. */ void blo_do_version_old_trackto_to_constraints(Object *ob) { /* create new trackto constraint from the relationship */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 79cd7678f90..1764395f639 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2175,10 +2175,10 @@ static void write_mesh(WriteData *wd, Mesh *mesh) /** * Those calls: - * - Reduce mesh->xdata.totlayer to number of layers to write. - * - Fill xlayers with those layers to be written. - * Note that mesh->xdata is from now on invalid for Blender, but this is why the whole mesh is - * a temp local copy! + * - Reduce mesh->xdata.totlayer to number of layers to write. + * - Fill xlayers with those layers to be written. + * Note that mesh->xdata is from now on invalid for Blender, + * but this is why the whole mesh is a temp local copy! */ CustomData_file_write_prepare( &mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff)); @@ -3740,9 +3740,10 @@ static void write_libraries(WriteData *wd, Main *main) } } - /* to be able to restore quit.blend and temp saves, the packed blend has to be in undo buffers... */ - /* XXX needs rethink, just like save UI in undo files now - would be nice to append things only for the] - * quit.blend and temp saves */ + /* To be able to restore 'quit.blend' and temp saves, + * the packed blend has to be in undo buffers... */ + /* XXX needs rethink, just like save UI in undo files now - + * would be nice to append things only for the 'quit.blend' and temp saves. */ if (found_one) { /* Not overridable. */ @@ -3893,7 +3894,8 @@ static bool write_file_handle(Main *mainvar, NULL : BKE_override_static_operations_store_initialize(); - /* This outer loop allows to save first datablocks from real mainvar, then the temp ones from override process, + /* This outer loop allows to save first datablocks from real mainvar, + * then the temp ones from override process, * if needed, without duplicating whole code. */ Main *bmain = mainvar; do { @@ -3907,7 +3909,8 @@ static bool write_file_handle(Main *mainvar, } for (; id; id = id->next) { - /* We should never attempt to write non-regular IDs (i.e. all kind of temp/runtime ones). */ + /* We should never attempt to write non-regular IDs + * (i.e. all kind of temp/runtime ones). */ BLI_assert( (id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0); -- cgit v1.2.3