Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/readfile.c
| Show First 20 Lines • Show All 3,910 Lines • ▼ Show 20 Lines | static void lib_link_all(FileData *fd, Main *bmain) | ||||
| FOREACH_MAIN_ID_END; | FOREACH_MAIN_ID_END; | ||||
| /* Cleanup `ID.orig_id`, this is now reserved for depsgraph/COW usage only. */ | /* Cleanup `ID.orig_id`, this is now reserved for depsgraph/COW usage only. */ | ||||
| FOREACH_MAIN_ID_BEGIN (bmain, id) { | FOREACH_MAIN_ID_BEGIN (bmain, id) { | ||||
| id->orig_id = NULL; | id->orig_id = NULL; | ||||
| } | } | ||||
| FOREACH_MAIN_ID_END; | FOREACH_MAIN_ID_END; | ||||
| #ifndef NDEBUG | |||||
| /* Double check we do not have any 'need link' tag remaining, this should never be the case once | |||||
| * this function has run. */ | |||||
| FOREACH_MAIN_ID_BEGIN (bmain, id) { | |||||
| BLI_assert((id->tag & LIB_TAG_NEED_LINK) == 0); | |||||
| } | |||||
| FOREACH_MAIN_ID_END; | |||||
| #endif | |||||
| } | |||||
| /* Checks to perform after `lib_link_all`. | |||||
| * Those operations cannot perfom properly in a split bmain case, since some data from other | |||||
| * bmain's (aka libraries) may not have been processed yet. */ | |||||
| static void after_liblink_merged_bmain_process(Main *bmain) | |||||
| { | |||||
| /* We only expect a merged Main here, not a split one. */ | |||||
| BLI_assert((bmain->prev == NULL) && (bmain->next == NULL)); | |||||
| /* Check for possible cycles in scenes' 'set' background property. */ | /* Check for possible cycles in scenes' 'set' background property. */ | ||||
| lib_link_scenes_check_set(bmain); | lib_link_scenes_check_set(bmain); | ||||
| /* We could integrate that to mesh/curve/lattice lib_link, but this is really cheap process, | /* We could integrate that to mesh/curve/lattice lib_link, but this is really cheap process, | ||||
| * so simpler to just use it directly in this single call. */ | * so simpler to just use it directly in this single call. */ | ||||
| BLO_main_validate_shapekeys(bmain, NULL); | BLO_main_validate_shapekeys(bmain, NULL); | ||||
| /* We have to rebuild that runtime information *after* all data-blocks have been properly linked. | /* We have to rebuild that runtime information *after* all data-blocks have been properly linked. | ||||
| */ | */ | ||||
| BKE_main_collections_parent_relations_rebuild(bmain); | BKE_main_collections_parent_relations_rebuild(bmain); | ||||
| #ifndef NDEBUG | |||||
| /* Double check we do not have any 'need link' tag remaining, this should never be the case once | |||||
| * this function has run. */ | |||||
| FOREACH_MAIN_ID_BEGIN (bmain, id) { | |||||
| BLI_assert((id->tag & LIB_TAG_NEED_LINK) == 0); | |||||
| } | |||||
| FOREACH_MAIN_ID_END; | |||||
| #endif | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Read User Preferences | /** \name Read User Preferences | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Lines | BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) | ||||
| } | } | ||||
| if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) { | if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) { | ||||
| read_libraries(fd, &mainlist); | read_libraries(fd, &mainlist); | ||||
| blo_join_main(&mainlist); | blo_join_main(&mainlist); | ||||
| lib_link_all(fd, bfd->main); | lib_link_all(fd, bfd->main); | ||||
| after_liblink_merged_bmain_process(bfd->main); | |||||
| /* Skip in undo case. */ | /* Skip in undo case. */ | ||||
| if (fd->memfile == NULL) { | if (fd->memfile == NULL) { | ||||
| /* Note that we can't recompute user-counts at this point in undo case, we play too much with | /* Note that we can't recompute user-counts at this point in undo case, we play too much with | ||||
| * IDs from different memory realms, and Main database is not in a fully valid state yet. | * IDs from different memory realms, and Main database is not in a fully valid state yet. | ||||
| */ | */ | ||||
| /* Some versioning code does expect some proper user-reference-counting, e.g. in conversion | /* Some versioning code does expect some proper user-reference-counting, e.g. in conversion | ||||
| * from groups to collections... We could optimize out that first call when we are reading a | * from groups to collections... We could optimize out that first call when we are reading a | ||||
| ▲ Show 20 Lines • Show All 932 Lines • ▼ Show 20 Lines | if (flag & FILE_RELPATH) { | ||||
| BLI_path_rel(curlib->filepath, BKE_main_blendfile_path_from_global()); | BLI_path_rel(curlib->filepath, BKE_main_blendfile_path_from_global()); | ||||
| } | } | ||||
| blo_join_main((*fd)->mainlist); | blo_join_main((*fd)->mainlist); | ||||
| mainvar = (*fd)->mainlist->first; | mainvar = (*fd)->mainlist->first; | ||||
| mainl = NULL; /* blo_join_main free's mainl, cant use anymore */ | mainl = NULL; /* blo_join_main free's mainl, cant use anymore */ | ||||
| lib_link_all(*fd, mainvar); | lib_link_all(*fd, mainvar); | ||||
| after_liblink_merged_bmain_process(mainvar); | |||||
| /* Some versioning code does expect some proper userrefcounting, e.g. in conversion from | /* Some versioning code does expect some proper userrefcounting, e.g. in conversion from | ||||
| * groups to collections... We could optimize out that first call when we are reading a | * groups to collections... We could optimize out that first call when we are reading a | ||||
| * current version file, but again this is really not a bottle neck currently. so not worth | * current version file, but again this is really not a bottle neck currently. so not worth | ||||
| * it. */ | * it. */ | ||||
| BKE_main_id_refcount_recompute(mainvar, false); | BKE_main_id_refcount_recompute(mainvar, false); | ||||
| BKE_collections_after_lib_link(mainvar); | BKE_collections_after_lib_link(mainvar); | ||||
| ▲ Show 20 Lines • Show All 604 Lines • Show Last 20 Lines | |||||