diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2020-08-08 13:49:41 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2020-08-08 13:49:41 +0300 |
commit | 843eccb200597b8128a04c623456a2f9f4d9ee34 (patch) | |
tree | 6de84a33ace17e6ff4f3046a31d517c3dc27716c /source/blender/blenloader | |
parent | c57ce2eb0b715360148966c55f4d766401898b5e (diff) | |
parent | a1d57e3f05f1602a07698e19f97f861d41f14775 (diff) |
Merge branch 'master' into greasepencil-edit-curve
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/BLO_blend_defs.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_blend_validate.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_read_write.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_readfile.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_undofile.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/BLO_writefile.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readblenentry.c | 45 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 149 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.h | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_250.c | 5 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_260.c | 13 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 8 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 46 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 18 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_cycles.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_legacy.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 30 |
17 files changed, 180 insertions, 174 deletions
diff --git a/source/blender/blenloader/BLO_blend_defs.h b/source/blender/blenloader/BLO_blend_defs.h index fec61605dca..40da63f20e8 100644 --- a/source/blender/blenloader/BLO_blend_defs.h +++ b/source/blender/blenloader/BLO_blend_defs.h @@ -13,8 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __BLO_BLEND_DEFS_H__ -#define __BLO_BLEND_DEFS_H__ +#pragma once /** \file * \ingroup blenloader @@ -72,5 +71,3 @@ enum { }; #define BLEN_THUMB_MEMSIZE_FILE(_x, _y) (sizeof(int) * (2 + (size_t)(_x) * (size_t)(_y))) - -#endif /* __BLO_BLEND_DEFS_H__ */ diff --git a/source/blender/blenloader/BLO_blend_validate.h b/source/blender/blenloader/BLO_blend_validate.h index 1ffaddef02f..78aa481d4b1 100644 --- a/source/blender/blenloader/BLO_blend_validate.h +++ b/source/blender/blenloader/BLO_blend_validate.h @@ -17,8 +17,7 @@ * All rights reserved. */ -#ifndef __BLO_BLEND_VALIDATE_H__ -#define __BLO_BLEND_VALIDATE_H__ +#pragma once /** \file * \ingroup blenloader @@ -31,5 +30,3 @@ struct ReportList; bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports); bool BLO_main_validate_shapekeys(struct Main *bmain, struct ReportList *reports); - -#endif diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h index 7c9738b67c5..024b6a6c5e4 100644 --- a/source/blender/blenloader/BLO_read_write.h +++ b/source/blender/blenloader/BLO_read_write.h @@ -38,8 +38,7 @@ * necessary. */ -#ifndef __BLO_READ_WRITE_H__ -#define __BLO_READ_WRITE_H__ +#pragma once /* for SDNA_TYPE_FROM_STRUCT() macro */ #include "dna_type_offsets.h" @@ -223,5 +222,3 @@ void BLO_expand_id(BlendExpander *expander, struct ID *id); #ifdef __cplusplus } #endif - -#endif /* __BLO_READ_WRITE_H__ */ diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index e4908eb7257..97c77ed2e19 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -16,8 +16,7 @@ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. */ -#ifndef __BLO_READFILE_H__ -#define __BLO_READFILE_H__ +#pragma once #include "BLI_sys_types.h" @@ -196,5 +195,3 @@ extern const struct UserDef U_default; #ifdef __cplusplus } #endif - -#endif /* __BLO_READFILE_H__ */ diff --git a/source/blender/blenloader/BLO_undofile.h b/source/blender/blenloader/BLO_undofile.h index f9300f8a521..f5527c13429 100644 --- a/source/blender/blenloader/BLO_undofile.h +++ b/source/blender/blenloader/BLO_undofile.h @@ -18,8 +18,7 @@ * external writefile function prototypes */ -#ifndef __BLO_UNDOFILE_H__ -#define __BLO_UNDOFILE_H__ +#pragma once /** \file * \ingroup blenloader @@ -85,5 +84,3 @@ extern struct Main *BLO_memfile_main_get(struct MemFile *memfile, struct Main *bmain, struct Scene **r_scene); extern bool BLO_memfile_write_file(struct MemFile *memfile, const char *filename); - -#endif /* __BLO_UNDOFILE_H__ */ diff --git a/source/blender/blenloader/BLO_writefile.h b/source/blender/blenloader/BLO_writefile.h index 8fe04e764f9..746c663926d 100644 --- a/source/blender/blenloader/BLO_writefile.h +++ b/source/blender/blenloader/BLO_writefile.h @@ -17,8 +17,7 @@ * All rights reserved. */ -#ifndef __BLO_WRITEFILE_H__ -#define __BLO_WRITEFILE_H__ +#pragma once /** \file * \ingroup blenloader @@ -73,5 +72,3 @@ extern bool BLO_write_file_mem(struct Main *mainvar, int write_flags); /** \} */ - -#endif diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index cb2094d050f..888863dda06 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -102,28 +102,27 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp) if (bhead->code == ENDB) { break; } - else { - const short *sp = fd->filesdna->structs[bhead->SDNAnr]; - const char *name = fd->filesdna->types[sp[0]]; - char buf[4]; - - buf[0] = (bhead->code >> 24) & 0xFF; - buf[1] = (bhead->code >> 16) & 0xFF; - buf[2] = (bhead->code >> 8) & 0xFF; - buf[3] = (bhead->code >> 0) & 0xFF; - - buf[0] = buf[0] ? buf[0] : ' '; - buf[1] = buf[1] ? buf[1] : ' '; - buf[2] = buf[2] ? buf[2] : ' '; - buf[3] = buf[3] ? buf[3] : ' '; - - fprintf(fp, - "['%.4s', '%s', %d, %ld ],\n", - buf, - name, - bhead->nr, - (long int)(bhead->len + sizeof(BHead))); - } + + const short *sp = fd->filesdna->structs[bhead->SDNAnr]; + const char *name = fd->filesdna->types[sp[0]]; + char buf[4]; + + buf[0] = (bhead->code >> 24) & 0xFF; + buf[1] = (bhead->code >> 16) & 0xFF; + buf[2] = (bhead->code >> 8) & 0xFF; + buf[3] = (bhead->code >> 0) & 0xFF; + + buf[0] = buf[0] ? buf[0] : ' '; + buf[1] = buf[1] ? buf[1] : ' '; + buf[2] = buf[2] ? buf[2] : ' '; + buf[3] = buf[3] ? buf[3] : ' '; + + fprintf(fp, + "['%.4s', '%s', %d, %ld ],\n", + buf, + name, + bhead->nr, + (long int)(bhead->len + sizeof(BHead))); } fprintf(fp, "]\n"); } @@ -268,7 +267,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) if (bhead->code == ENDB) { break; } - else if (BKE_idtype_idcode_is_valid(bhead->code)) { + if (BKE_idtype_idcode_is_valid(bhead->code)) { if (BKE_idtype_idcode_is_linkable(bhead->code)) { const char *str = BKE_idtype_idcode_to_name(bhead->code); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 462ba170d70..27f282cb760 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -373,7 +373,7 @@ static void oldnewmap_insert_or_replace(OldNewMap *onm, OldNew entry) onm->nentries++; break; } - else if (onm->entries[index].oldp == entry.oldp) { + if (onm->entries[index].oldp == entry.oldp) { onm->entries[index] = entry; break; } @@ -1112,9 +1112,8 @@ static bool read_file_dna(FileData *fd, const char **r_error_message) return true; } - else { - return false; - } + + return false; } else if (bhead->code == ENDB) { break; @@ -1135,7 +1134,7 @@ static int *read_file_thumbnail(FileData *fd) const bool do_endian_swap = (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0; int *data = (int *)(bhead + 1); - if (bhead->len < (2 * sizeof(int))) { + if (bhead->len < (sizeof(int[2]))) { break; } @@ -1156,7 +1155,7 @@ static int *read_file_thumbnail(FileData *fd) blend_thumb = data; break; } - else if (bhead->code != REND) { + if (bhead->code != REND) { /* Thumbnail is stored in TEST immediately after first REND... */ break; } @@ -1187,7 +1186,7 @@ static int fd_read_data_from_file(FileData *filedata, filedata->file_offset += readsize; } - return (readsize); + return readsize; } static off64_t fd_seek_data_from_file(FileData *filedata, off64_t offset, int whence) @@ -1212,7 +1211,7 @@ static int fd_read_gzip_from_file(FileData *filedata, filedata->file_offset += readsize; } - return (readsize); + return readsize; } /* Memory reading. */ @@ -1228,7 +1227,7 @@ static int fd_read_from_memory(FileData *filedata, memcpy(buffer, filedata->buffer + filedata->file_offset, readsize); filedata->file_offset += readsize; - return (readsize); + return readsize; } /* MemFile reading. */ @@ -1373,9 +1372,8 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath, errno ? strerror(errno) : TIP_("insufficient content")); return NULL; } - else { - BLI_lseek(file, 0, SEEK_SET); - } + + BLI_lseek(file, 0, SEEK_SET); /* Regular file. */ if (memcmp(header, "BLENDER", sizeof(header)) == 0) { @@ -1397,12 +1395,11 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath, errno ? strerror(errno) : TIP_("unknown error reading file")); return NULL; } - else { - /* 'seek_fn' is too slow for gzip, don't set it. */ - read_fn = fd_read_gzip_from_file; - /* Caller must close. */ - file = -1; - } + + /* 'seek_fn' is too slow for gzip, don't set it. */ + read_fn = fd_read_gzip_from_file; + /* Caller must close. */ + file = -1; } if (read_fn == NULL) { @@ -1487,14 +1484,14 @@ static int fd_read_gzip_from_memory(FileData *filedata, if (err == Z_STREAM_END) { return 0; } - else if (err != Z_OK) { + if (err != Z_OK) { printf("fd_read_gzip_from_memory: zlib error\n"); return 0; } filedata->file_offset += size; - return (size); + return size; } static int fd_read_gzip_from_memory_init(FileData *fd) @@ -1521,28 +1518,27 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *rep BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open")); return NULL; } - else { - FileData *fd = filedata_new(); - const char *cp = mem; - fd->buffer = mem; - fd->buffersize = memsize; + FileData *fd = filedata_new(); + const char *cp = mem; - /* test if gzip */ - if (cp[0] == 0x1f && cp[1] == 0x8b) { - if (0 == fd_read_gzip_from_memory_init(fd)) { - blo_filedata_free(fd); - return NULL; - } - } - else { - fd->read = fd_read_from_memory; + fd->buffer = mem; + fd->buffersize = memsize; + + /* test if gzip */ + if (cp[0] == 0x1f && cp[1] == 0x8b) { + if (0 == fd_read_gzip_from_memory_init(fd)) { + blo_filedata_free(fd); + return NULL; } + } + else { + fd->read = fd_read_from_memory; + } - fd->flags |= FD_FLAGS_NOT_MY_BUFFER; + fd->flags |= FD_FLAGS_NOT_MY_BUFFER; - return blo_decode_and_check(fd, reports); - } + return blo_decode_and_check(fd, reports); } FileData *blo_filedata_from_memfile(MemFile *memfile, @@ -1553,16 +1549,15 @@ FileData *blo_filedata_from_memfile(MemFile *memfile, BKE_report(reports, RPT_WARNING, "Unable to open blend <memory>"); return NULL; } - else { - FileData *fd = filedata_new(); - fd->memfile = memfile; - fd->undo_direction = params->undo_direction; - fd->read = fd_read_from_memfile; - fd->flags |= FD_FLAGS_NOT_MY_BUFFER; + FileData *fd = filedata_new(); + fd->memfile = memfile; + fd->undo_direction = params->undo_direction; - return blo_decode_and_check(fd, reports); - } + fd->read = fd_read_from_memfile; + fd->flags |= FD_FLAGS_NOT_MY_BUFFER; + + return blo_decode_and_check(fd, reports); } void blo_filedata_free(FileData *fd) @@ -1695,7 +1690,7 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) { break; } - else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) { + if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) { break; } @@ -6093,6 +6088,14 @@ static bool scene_validate_setscene__liblink(Scene *sce, const int totscene) } for (a = 0, sce_iter = sce; sce_iter->set; sce_iter = sce_iter->set, a++) { + /* This runs per library (before each libraries #Main has been joined), + * so we can't step into other libraries since `totscene` is only for this library. + * + * Also, other libraries may not have been linked yet, + * while we could check #LIB_TAG_NEED_LINK the library pointer check is sufficient. */ + if (sce->id.lib != sce_iter->id.lib) { + return true; + } if (sce_iter->flag & SCE_READFILE_LIBLINK_NEED_SETSCENE_CHECK) { return true; } @@ -6968,31 +6971,31 @@ static void direct_link_area(BlendDataReader *reader, ScrArea *area) BLO_read_data_address(reader, &snla->ads); } else if (sl->spacetype == SPACE_OUTLINER) { - SpaceOutliner *soops = (SpaceOutliner *)sl; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; /* use newdataadr_no_us and do not free old memory avoiding double * frees and use of freed memory. this could happen because of a * bug fixed in revision 58959 where the treestore memory address * was not unique */ - TreeStore *ts = newdataadr_no_us(reader->fd, soops->treestore); - soops->treestore = NULL; + TreeStore *ts = newdataadr_no_us(reader->fd, space_outliner->treestore); + space_outliner->treestore = NULL; if (ts) { TreeStoreElem *elems = newdataadr_no_us(reader->fd, ts->data); - soops->treestore = BLI_mempool_create( + space_outliner->treestore = BLI_mempool_create( sizeof(TreeStoreElem), ts->usedelem, 512, BLI_MEMPOOL_ALLOW_ITER); if (ts->usedelem && elems) { int i; for (i = 0; i < ts->usedelem; i++) { - TreeStoreElem *new_elem = BLI_mempool_alloc(soops->treestore); + TreeStoreElem *new_elem = BLI_mempool_alloc(space_outliner->treestore); *new_elem = elems[i]; } } /* we only saved what was used */ - soops->storeflag |= SO_TREESTORE_CLEANUP; // at first draw + space_outliner->storeflag |= SO_TREESTORE_CLEANUP; // at first draw } - soops->treehash = NULL; - soops->tree.first = soops->tree.last = NULL; + space_outliner->treehash = NULL; + space_outliner->tree.first = space_outliner->tree.last = NULL; } else if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; @@ -7219,20 +7222,20 @@ static void lib_link_area(BlendLibReader *reader, ID *parent_id, ScrArea *area) break; } case SPACE_OUTLINER: { - SpaceOutliner *so = (SpaceOutliner *)sl; - BLO_read_id_address(reader, NULL, &so->search_tse.id); + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; + BLO_read_id_address(reader, NULL, &space_outliner->search_tse.id); - if (so->treestore) { + if (space_outliner->treestore) { TreeStoreElem *tselem; BLI_mempool_iter iter; - BLI_mempool_iternew(so->treestore, &iter); + BLI_mempool_iternew(space_outliner->treestore, &iter); while ((tselem = BLI_mempool_iterstep(&iter))) { BLO_read_id_address(reader, NULL, &tselem->id); } - if (so->treehash) { + if (space_outliner->treehash) { /* rebuild hash table, because it depends on ids too */ - so->storeflag |= SO_TREESTORE_REBUILD; + space_outliner->storeflag |= SO_TREESTORE_REBUILD; } } break; @@ -7791,15 +7794,16 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, } } else if (sl->spacetype == SPACE_OUTLINER) { - SpaceOutliner *so = (SpaceOutliner *)sl; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; - so->search_tse.id = restore_pointer_by_name(id_map, so->search_tse.id, USER_IGNORE); + space_outliner->search_tse.id = restore_pointer_by_name( + id_map, space_outliner->search_tse.id, USER_IGNORE); - if (so->treestore) { + if (space_outliner->treestore) { TreeStoreElem *tselem; BLI_mempool_iter iter; - BLI_mempool_iternew(so->treestore, &iter); + BLI_mempool_iternew(space_outliner->treestore, &iter); while ((tselem = BLI_mempool_iterstep(&iter))) { /* Do not try to restore pointers to drivers/sequence/etc., * can crash in undo case! */ @@ -7810,9 +7814,9 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, tselem->id = NULL; } } - if (so->treehash) { + if (space_outliner->treehash) { /* rebuild hash table, because it depends on ids too */ - so->storeflag |= SO_TREESTORE_REBUILD; + space_outliner->storeflag |= SO_TREESTORE_REBUILD; } } } @@ -9252,17 +9256,16 @@ static bool read_libblock_undo_restore( *r_id_old = id_old; return true; } - else if (id_old != NULL) { + if (id_old != NULL) { /* Local datablock was changed. Restore at the address of the old datablock. */ DEBUG_PRINTF("read to old existing address\n"); *r_id_old = id_old; return false; } - else { - /* Local datablock does not exist in the undo step, so read from scratch. */ - DEBUG_PRINTF("read at new address\n"); - return false; - } + + /* Local datablock does not exist in the undo step, so read from scratch. */ + DEBUG_PRINTF("read at new address\n"); + return false; } /* This routine reads a datablock and its direct data, and advances bhead to @@ -10033,7 +10036,7 @@ static int verg_bheadsort(const void *v1, const void *v2) if (x1->old > x2->old) { return 1; } - else if (x1->old < x2->old) { + if (x1->old < x2->old) { return -1; } return 0; diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index f8c91c77634..34a670a8357 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -22,8 +22,7 @@ * \ingroup blenloader */ -#ifndef __READFILE_H__ -#define __READFILE_H__ +#pragma once #include "DNA_sdna_types.h" #include "DNA_space_types.h" @@ -199,5 +198,3 @@ void do_versions_after_linking_270(struct Main *bmain); void do_versions_after_linking_280(struct Main *bmain, struct ReportList *reports); void do_versions_after_linking_290(struct Main *bmain, struct ReportList *reports); void do_versions_after_linking_cycles(struct Main *bmain); - -#endif diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 1432fbeb4e2..0e753c84476 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -270,9 +270,9 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) break; case SPACE_OUTLINER: { - SpaceOutliner *soops = (SpaceOutliner *)sl; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; - memcpy(®ion->v2d, &soops->v2d, sizeof(View2D)); + memcpy(®ion->v2d, &space_outliner->v2d, sizeof(View2D)); region->v2d.scroll &= ~V2D_SCROLL_LEFT; region->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); @@ -635,6 +635,7 @@ static void do_versions_socket_default_value_259(bNodeSocket *sock) } } +/* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_250(FileData *fd, Library *lib, Main *bmain) { /* WATCH IT!!!: pointers from libdata have not been converted */ diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index f74ee9cd735..1ac90398c0a 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -658,6 +658,7 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro } } +/* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) { if (bmain->versionfile < 260) { @@ -2348,10 +2349,14 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) for (area = screen->areabase.first; area; area = area->next) { for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { - SpaceOutliner *so = (SpaceOutliner *)sl; - - if (!ELEM(so->outlinevis, SO_SCENES, SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API)) { - so->outlinevis = SO_SCENES; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; + + if (!ELEM(space_outliner->outlinevis, + SO_SCENES, + SO_LIBRARIES, + SO_SEQUENCE, + SO_DATA_API)) { + space_outliner->outlinevis = SO_SCENES; } } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 2c4602f546b..b19c6221391 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -242,7 +242,7 @@ static void do_version_action_editor_properties_region(ListBase *regionbase) /* already exists */ return; } - else if (region->regiontype == RGN_TYPE_WINDOW) { + if (region->regiontype == RGN_TYPE_WINDOW) { /* add new region here */ ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action"); @@ -377,9 +377,8 @@ static char *replace_bbone_easing_rnapath(char *old_path) MEM_freeN(old_path); return new_path; } - else { - return old_path; - } + + return old_path; } static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), @@ -421,6 +420,7 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), } } +/* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) { if (!MAIN_VERSION_ATLEAST(bmain, 270, 0)) { diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 4e3f701bacc..12099956f4b 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1201,7 +1201,7 @@ static void do_version_fcurve_hide_viewport_fix(struct ID *UNUSED(id), struct FCurve *fcu, void *UNUSED(user_data)) { - if (strcmp(fcu->rna_path, "hide")) { + if (!STREQ(fcu->rna_path, "hide")) { return; } @@ -1282,20 +1282,20 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports)) LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) { if (space->spacetype == SPACE_OUTLINER) { - SpaceOutliner *soutliner = (SpaceOutliner *)space; + SpaceOutliner *space_outliner = (SpaceOutliner *)space; - soutliner->outlinevis = SO_VIEW_LAYER; + space_outliner->outlinevis = SO_VIEW_LAYER; if (BLI_listbase_count_at_most(&layer->layer_collections, 2) == 1) { - if (soutliner->treestore == NULL) { - soutliner->treestore = BLI_mempool_create( + if (space_outliner->treestore == NULL) { + space_outliner->treestore = BLI_mempool_create( sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER); } /* Create a tree store element for the collection. This is normally * done in check_persistent (outliner_tree.c), but we need to access * it here :/ (expand element if it's the only one) */ - TreeStoreElem *tselem = BLI_mempool_calloc(soutliner->treestore); + TreeStoreElem *tselem = BLI_mempool_calloc(space_outliner->treestore); tselem->type = TSE_LAYER_COLLECTION; tselem->id = layer->layer_collections.first; tselem->nr = tselem->used = 0; @@ -1792,6 +1792,7 @@ static void do_versions_seq_set_cache_defaults(Editing *ed) ed->recycle_max_cost = 10.0f; } +/* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) { bool use_collection_compat_28 = true; @@ -2024,15 +2025,15 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (area = screen->areabase.first; area; area = area->next) { for (sl = area->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_OUTLINER) { - SpaceOutliner *so = (SpaceOutliner *)sl; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; - if (!ELEM(so->outlinevis, + if (!ELEM(space_outliner->outlinevis, SO_SCENES, SO_LIBRARIES, SO_SEQUENCE, SO_DATA_API, SO_ID_ORPHANS)) { - so->outlinevis = SO_VIEW_LAYER; + space_outliner->outlinevis = SO_VIEW_LAYER; } } } @@ -2412,9 +2413,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) 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; - soops->outlinevis = SO_VIEW_LAYER; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; + space_outliner->filter_id_type = ID_GR; + space_outliner->outlinevis = SO_VIEW_LAYER; } } } @@ -3341,7 +3342,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) 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); + memcpy(v3d->shading.lookdev_light, v3d->shading.studio_light, sizeof(char[256])); } } } @@ -3411,9 +3412,10 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) break; } case SPACE_OUTLINER: { - SpaceOutliner *so = (SpaceOutliner *)sl; - so->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 | SO_FILTER_UNUSED_12); - so->storeflag &= ~(SO_TREESTORE_UNUSED_1); + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; + space_outliner->filter &= ~(SO_FILTER_UNUSED_1 | SO_FILTER_UNUSED_5 | + SO_FILTER_UNUSED_12); + space_outliner->storeflag &= ~(SO_TREESTORE_UNUSED_1); break; } case SPACE_FILE: { @@ -4027,9 +4029,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (sl->spacetype != SPACE_OUTLINER) { continue; } - SpaceOutliner *so = (SpaceOutliner *)sl; - so->filter &= ~SO_FLAG_UNUSED_1; - so->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; + space_outliner->filter &= ~SO_FLAG_UNUSED_1; + space_outliner->show_restrict_flags = SO_RESTRICT_ENABLE | SO_RESTRICT_HIDE; } } } @@ -4161,9 +4163,9 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } /* Mark outliners as dirty for syncing and enable synced selection */ if (sl->spacetype == SPACE_OUTLINER) { - SpaceOutliner *soutliner = (SpaceOutliner *)sl; - soutliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL; - soutliner->flag |= SO_SYNC_SELECT; + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; + space_outliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL; + space_outliner->flag |= SO_SYNC_SELECT; } } } diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 94c9b125706..e9754073548 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -38,6 +38,7 @@ #include "BKE_collection.h" #include "BKE_colortools.h" +#include "BKE_gpencil.h" #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_node.h" @@ -186,6 +187,23 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) } } } + + /* Patch first frame for old files. */ + Scene *scene = bmain->scenes.first; + LISTBASE_FOREACH (Object *, ob, &bmain->objects) { + if (ob->type != OB_GPENCIL) { + continue; + } + bGPdata *gpd = ob->data; + LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { + bGPDframe *gpf = gpl->frames.first; + if (gpf && gpf->framenum > scene->r.sfra) { + bGPDframe *gpf_dup = BKE_gpencil_frame_duplicate(gpf); + gpf_dup->framenum = scene->r.sfra; + BLI_addhead(&gpl->frames, gpf_dup); + } + } + } } /** diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index 46faddf6e5a..26329fca6fa 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -1447,7 +1447,7 @@ void do_versions_after_linking_cycles(Main *bmain) if (is_fstop) { continue; } - else if (aperture_size > 0.0f) { + if (aperture_size > 0.0f) { if (camera->type == CAM_ORTHO) { camera->dof.aperture_fstop = 1.0f / (2.0f * aperture_size); } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index d25e340d4fc..88ccb551e16 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -102,7 +102,7 @@ static void vcol_to_fcol(Mesh *me) return; } - mcoln = mcolmain = MEM_malloc_arrayN(me->totface, 4 * sizeof(int), "mcoln"); + mcoln = mcolmain = MEM_malloc_arrayN(me->totface, sizeof(int[4]), "mcoln"); mcol = (uint *)me->mcol; mface = me->mface; for (a = me->totface; a > 0; a--, mface++) { @@ -493,6 +493,7 @@ void blo_do_version_old_trackto_to_constraints(Object *ob) ob->track = NULL; } +/* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) { /* WATCH IT!!!: pointers from libdata have not been converted */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 285d58ce34a..82bc042240f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -240,9 +240,8 @@ static bool ww_open_none(WriteWrap *ww, const char *filepath) FILE_HANDLE(ww) = file; return true; } - else { - return false; - } + + return false; } static bool ww_close_none(WriteWrap *ww) { @@ -267,9 +266,8 @@ static bool ww_open_zlib(WriteWrap *ww, const char *filepath) FILE_HANDLE(ww) = file; return true; } - else { - return false; - } + + return false; } static bool ww_close_zlib(WriteWrap *ww) { @@ -2847,12 +2845,12 @@ static void write_uilist(BlendWriter *writer, uiList *ui_list) } } -static void write_soops(BlendWriter *writer, SpaceOutliner *so) +static void write_space_outliner(BlendWriter *writer, SpaceOutliner *space_outliner) { - BLI_mempool *ts = so->treestore; + BLI_mempool *ts = space_outliner->treestore; if (ts) { - SpaceOutliner so_flat = *so; + SpaceOutliner space_outliner_flat = *space_outliner; int elems = BLI_mempool_len(ts); /* linearize mempool to array */ @@ -2873,7 +2871,7 @@ static void write_soops(BlendWriter *writer, SpaceOutliner *so) ts_flat.totelem = elems; ts_flat.data = data_addr; - BLO_write_struct(writer, SpaceOutliner, so); + BLO_write_struct(writer, SpaceOutliner, space_outliner); BLO_write_struct_at_address(writer, TreeStore, ts, &ts_flat); BLO_write_struct_array_at_address(writer, TreeStoreElem, elems, data_addr, data); @@ -2881,12 +2879,12 @@ static void write_soops(BlendWriter *writer, SpaceOutliner *so) MEM_freeN(data); } else { - so_flat.treestore = NULL; - BLO_write_struct_at_address(writer, SpaceOutliner, so, &so_flat); + space_outliner_flat.treestore = NULL; + BLO_write_struct_at_address(writer, SpaceOutliner, space_outliner, &space_outliner_flat); } } else { - BLO_write_struct(writer, SpaceOutliner, so); + BLO_write_struct(writer, SpaceOutliner, space_outliner); } } @@ -2962,8 +2960,8 @@ static void write_area_regions(BlendWriter *writer, ScrArea *area) BLO_write_struct(writer, SpaceSeq, sl); } else if (sl->spacetype == SPACE_OUTLINER) { - SpaceOutliner *so = (SpaceOutliner *)sl; - write_soops(writer, so); + SpaceOutliner *space_outliner = (SpaceOutliner *)sl; + write_space_outliner(writer, space_outliner); } else if (sl->spacetype == SPACE_IMAGE) { BLO_write_struct(writer, SpaceImage, sl); @@ -4612,7 +4610,7 @@ void BLO_write_pointer_array(BlendWriter *writer, int size, const void *data_ptr void BLO_write_float3_array(BlendWriter *writer, int size, const float *data_ptr) { - BLO_write_raw(writer, sizeof(float) * 3 * size, data_ptr); + BLO_write_raw(writer, sizeof(float[3]) * size, data_ptr); } /** |