diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-05-13 05:36:14 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-05-13 05:36:14 +0300 |
commit | d7eed63b6d74332407a0744f0e0044ab13632702 (patch) | |
tree | 3956c699fa7c0dd2f80fa647af905c7b43503cff /source | |
parent | 05f1451d724874e12b3f1373e83849dbb4960ef6 (diff) |
readfile: support preferences without loading data-blocks
Needed to support reading preferences without replacing blend file data.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 227aa6a2ec6..288fa92da38 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -9629,14 +9629,17 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) ListBase mainlist = {NULL, NULL}; bfd = MEM_callocN(sizeof(BlendFileData), "blendfiledata"); - bfd->main = BKE_main_new(); - BLI_addtail(&mainlist, bfd->main); - fd->mainlist = &mainlist; + bfd->main = BKE_main_new(); bfd->main->versionfile = fd->fileversion; bfd->type = BLENFILETYPE_BLEND; - BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name)); + + if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) { + BLI_addtail(&mainlist, bfd->main); + fd->mainlist = &mainlist; + BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name)); + } if (G.background) { /* We only read & store .blend thumbnail in background mode @@ -9714,45 +9717,52 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) /* do before read_libraries, but skip undo case */ if (fd->memfile == NULL) { - do_versions(fd, NULL, bfd->main); - do_versions_userdef(fd, bfd); + if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) { + do_versions(fd, NULL, bfd->main); + } + + if ((fd->skip_flags & BLO_READ_SKIP_USERDEF) == 0) { + do_versions_userdef(fd, bfd); + } } - read_libraries(fd, &mainlist); + if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) { + read_libraries(fd, &mainlist); - blo_join_main(&mainlist); + blo_join_main(&mainlist); - lib_link_all(fd, bfd->main); + lib_link_all(fd, bfd->main); - /* Skip in undo case. */ - if (fd->memfile == NULL) { - /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ - blo_split_main(&mainlist, bfd->main); - for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { - BLI_assert(mainvar->versionfile != 0); - do_versions_after_linking(mainvar); - } - blo_join_main(&mainlist); + /* Skip in undo case. */ + if (fd->memfile == NULL) { + /* Yep, second splitting... but this is a very cheap operation, so no big deal. */ + blo_split_main(&mainlist, bfd->main); + for (Main *mainvar = mainlist.first; mainvar; mainvar = mainvar->next) { + BLI_assert(mainvar->versionfile != 0); + do_versions_after_linking(mainvar); + } + blo_join_main(&mainlist); - /* After all data has been read and versioned, uses LIB_TAG_NEW. */ - ntreeUpdateAllNew(bfd->main); - } + /* After all data has been read and versioned, uses LIB_TAG_NEW. */ + ntreeUpdateAllNew(bfd->main); + } - BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false); + BKE_main_id_tag_all(bfd->main, LIB_TAG_NEW, false); - /* Now that all our data-blocks are loaded, - * we can re-generate overrides from their references. */ - if (fd->memfile == NULL) { - /* Do not apply in undo case! */ - BKE_main_override_static_update(bfd->main); - } + /* Now that all our data-blocks are loaded, + * we can re-generate overrides from their references. */ + if (fd->memfile == NULL) { + /* Do not apply in undo case! */ + BKE_main_override_static_update(bfd->main); + } - BKE_collections_after_lib_link(bfd->main); + BKE_collections_after_lib_link(bfd->main); - fix_relpaths_library(fd->relabase, - bfd->main); /* make all relative paths, relative to the open blend file */ + /* Make all relative paths, relative to the open blend file. */ + fix_relpaths_library(fd->relabase, bfd->main); - link_global(fd, bfd); /* as last */ + link_global(fd, bfd); /* as last */ + } fd->mainlist = NULL; /* Safety, this is local variable, shall not be used afterward. */ |