From 3a48147b8ab92e4828157ec7a3a1a75dd1a6b964 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 Jun 2021 19:11:06 +0200 Subject: Revert "Enhanced stats/reports for blendfile reading." This change crashes library linking operators, related tests and probably more. This reverts commit f8d219dfd4c31a918e33cb715472d91a5cd3fd51. Ref D11583 --- source/blender/blenkernel/BKE_blendfile.h | 7 +- source/blender/blenkernel/BKE_lib_override.h | 5 +- source/blender/blenkernel/intern/blender_undo.c | 7 +- source/blender/blenkernel/intern/blendfile.c | 33 ++---- source/blender/blenkernel/intern/lib_override.c | 32 +----- source/blender/blenloader/BLO_read_write.h | 11 +- source/blender/blenloader/BLO_readfile.h | 31 +----- source/blender/blenloader/intern/readblenentry.c | 8 +- source/blender/blenloader/intern/readfile.c | 41 ++++---- source/blender/blenloader/intern/readfile.h | 6 +- source/blender/blenloader/intern/versioning_280.c | 8 +- .../tests/blendfile_loading_base_test.cc | 3 +- .../editors/space_outliner/outliner_tools.c | 12 +-- source/blender/windowmanager/intern/wm_files.c | 116 ++------------------- 14 files changed, 69 insertions(+), 251 deletions(-) diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index 3e0a343a766..429e294a337 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -25,7 +25,6 @@ extern "C" { struct BlendFileData; struct BlendFileReadParams; -struct BlendFileReadReport; struct ID; struct Main; struct MemFile; @@ -36,7 +35,7 @@ struct bContext; void BKE_blendfile_read_setup_ex(struct bContext *C, struct BlendFileData *bfd, const struct BlendFileReadParams *params, - struct BlendFileReadReport *reports, + struct ReportList *reports, /* Extra args. */ const bool startup_update_defaults, const char *startup_app_template); @@ -44,11 +43,11 @@ void BKE_blendfile_read_setup_ex(struct bContext *C, void BKE_blendfile_read_setup(struct bContext *C, struct BlendFileData *bfd, const struct BlendFileReadParams *params, - struct BlendFileReadReport *reports); + struct ReportList *reports); struct BlendFileData *BKE_blendfile_read(const char *filepath, const struct BlendFileReadParams *params, - struct BlendFileReadReport *reports); + struct ReportList *reports); struct BlendFileData *BKE_blendfile_read_from_memory(const void *filebuf, int filelength, diff --git a/source/blender/blenkernel/BKE_lib_override.h b/source/blender/blenkernel/BKE_lib_override.h index 3eb0ff44129..4dc99e64cf2 100644 --- a/source/blender/blenkernel/BKE_lib_override.h +++ b/source/blender/blenkernel/BKE_lib_override.h @@ -43,7 +43,6 @@ extern "C" { #endif struct Collection; -struct BlendFileReadReport; struct ID; struct IDOverrideLibrary; struct IDOverrideLibraryProperty; @@ -91,11 +90,11 @@ bool BKE_lib_override_library_resync(struct Main *bmain, struct Collection *override_resync_residual_storage, const bool do_hierarchy_enforce, const bool do_post_process, - struct BlendFileReadReport *reports); + struct ReportList *reports); void BKE_lib_override_library_main_resync(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, - struct BlendFileReadReport *reports); + struct ReportList *reports); void BKE_lib_override_library_delete(struct Main *bmain, struct ID *id_root); diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index 6f47cd1336e..ba41786c7fd 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -78,10 +78,9 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, if (UNDO_DISK) { const struct BlendFileReadParams params = {0}; - struct BlendFileData *bfd = BKE_blendfile_read( - mfu->filename, ¶ms, &(BlendFileReadReport){NULL}); + struct BlendFileData *bfd = BKE_blendfile_read(mfu->filename, ¶ms, NULL); if (bfd != NULL) { - BKE_blendfile_read_setup(C, bfd, ¶ms, &(BlendFileReadReport){NULL}); + BKE_blendfile_read_setup(C, bfd, ¶ms, NULL); success = true; } } @@ -94,7 +93,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, struct BlendFileData *bfd = BKE_blendfile_read_from_memfile( bmain, &mfu->memfile, ¶ms, NULL); if (bfd != NULL) { - BKE_blendfile_read_setup(C, bfd, ¶ms, &(BlendFileReadReport){NULL}); + BKE_blendfile_read_setup(C, bfd, ¶ms, NULL); success = true; } } diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 3a59bc64652..54fd3f55c31 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -36,8 +36,6 @@ #include "BLI_system.h" #include "BLI_utildefines.h" -#include "PIL_time.h" - #include "IMB_colormanagement.h" #include "BKE_addon.h" @@ -138,7 +136,7 @@ static void setup_app_userdef(BlendFileData *bfd) static void setup_app_data(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - BlendFileReadReport *reports) + ReportList *reports) { Main *bmain = G_MAIN; Scene *curscene = NULL; @@ -157,7 +155,7 @@ static void setup_app_data(bContext *C, /* may happen with library files - UNDO file should never have NULL curscene (but may have a * NULL curscreen)... */ else if (ELEM(NULL, bfd->curscreen, bfd->curscene)) { - BKE_report(reports->reports, RPT_WARNING, "Library file, loading empty scene"); + BKE_report(reports, RPT_WARNING, "Library file, loading empty scene"); mode = LOAD_UI_OFF; } else if (G.fileflags & G_FILE_NO_UI) { @@ -398,17 +396,11 @@ static void setup_app_data(bContext *C, } if (mode != LOAD_UNDO && !USER_EXPERIMENTAL_TEST(&U, no_override_auto_resync)) { - reports->duration.lib_overrides_resync = PIL_check_seconds_timer(); - BKE_lib_override_library_main_resync( bmain, curscene, bfd->cur_view_layer ? bfd->cur_view_layer : BKE_view_layer_default_view(curscene), reports); - - reports->duration.lib_overrides_resync = PIL_check_seconds_timer() - - reports->duration.lib_overrides_resync; - /* We need to rebuild some of the deleted override rules (for UI feedback purpose). */ BKE_lib_override_library_main_operations_create(bmain, true); } @@ -417,7 +409,7 @@ static void setup_app_data(bContext *C, static void setup_app_blend_file_data(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - BlendFileReadReport *reports) + ReportList *reports) { if ((params->skip_flags & BLO_READ_SKIP_USERDEF) == 0) { setup_app_userdef(bfd); @@ -427,12 +419,12 @@ static void setup_app_blend_file_data(bContext *C, } } -static void handle_subversion_warning(Main *main, BlendFileReadReport *reports) +static void handle_subversion_warning(Main *main, ReportList *reports) { if (main->minversionfile > BLENDER_FILE_VERSION || (main->minversionfile == BLENDER_FILE_VERSION && main->minsubversionfile > BLENDER_FILE_SUBVERSION)) { - BKE_reportf(reports->reports, + BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary (%d.%d), expect loss of data!", main->minversionfile, @@ -451,7 +443,7 @@ static void handle_subversion_warning(Main *main, BlendFileReadReport *reports) void BKE_blendfile_read_setup_ex(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - BlendFileReadReport *reports, + ReportList *reports, /* Extra args. */ const bool startup_update_defaults, const char *startup_app_template) @@ -468,7 +460,7 @@ void BKE_blendfile_read_setup_ex(bContext *C, void BKE_blendfile_read_setup(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - BlendFileReadReport *reports) + ReportList *reports) { BKE_blendfile_read_setup_ex(C, bfd, params, reports, false, NULL); } @@ -478,7 +470,7 @@ void BKE_blendfile_read_setup(bContext *C, */ struct BlendFileData *BKE_blendfile_read(const char *filepath, const struct BlendFileReadParams *params, - BlendFileReadReport *reports) + ReportList *reports) { /* Don't print startup file loading. */ if (params->is_startup == false) { @@ -490,7 +482,7 @@ struct BlendFileData *BKE_blendfile_read(const char *filepath, handle_subversion_warning(bfd->main, reports); } else { - BKE_reports_prependf(reports->reports, "Loading '%s' failed: ", filepath); + BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath); } return bfd; } @@ -567,9 +559,7 @@ UserDef *BKE_blendfile_userdef_read(const char *filepath, ReportList *reports) BlendFileData *bfd; UserDef *userdef = NULL; - bfd = BLO_read_from_file(filepath, - BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, - &(struct BlendFileReadReport){.reports = reports}); + bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, reports); if (bfd) { if (bfd->user) { userdef = bfd->user; @@ -780,8 +770,7 @@ WorkspaceConfigFileData *BKE_blendfile_workspace_config_read(const char *filepat WorkspaceConfigFileData *workspace_config = NULL; if (filepath) { - bfd = BLO_read_from_file( - filepath, BLO_READ_SKIP_USERDEF, &(struct BlendFileReadReport){.reports = reports}); + bfd = BLO_read_from_file(filepath, BLO_READ_SKIP_USERDEF, reports); } else { bfd = BLO_read_from_memory(filebuf, filelength, BLO_READ_SKIP_USERDEF, reports); diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index 270d7ca358a..c93971e7b11 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -52,17 +52,12 @@ #include "BKE_report.h" #include "BKE_scene.h" -#include "BLO_readfile.h" - #include "BLI_ghash.h" -#include "BLI_linklist.h" #include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_task.h" #include "BLI_utildefines.h" -#include "PIL_time.h" - #include "RNA_access.h" #include "RNA_types.h" @@ -963,7 +958,7 @@ bool BKE_lib_override_library_resync(Main *bmain, Collection *override_resync_residual_storage, const bool do_hierarchy_enforce, const bool do_post_process, - BlendFileReadReport *reports) + ReportList *reports) { BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root)); @@ -1291,7 +1286,7 @@ bool BKE_lib_override_library_resync(Main *bmain, id_root = id_root_reference->newid; if (user_edited_overrides_deletion_count > 0) { - BKE_reportf(reports != NULL ? reports->reports : NULL, + BKE_reportf(reports, RPT_WARNING, "During resync of data-block %s, %d obsolete overrides were deleted, that had " "local changes defined by user", @@ -1443,11 +1438,8 @@ static void lib_override_library_main_resync_on_library_indirect_level( ViewLayer *view_layer, Collection *override_resync_residual_storage, const int library_indirect_level, - BlendFileReadReport *reports) + ReportList *reports) { - const bool do_reports_recursive_resync_timing = (library_indirect_level != 0); - const double init_time = do_reports_recursive_resync_timing ? PIL_check_seconds_timer() : 0.0; - BKE_main_relations_create(bmain, 0); BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); @@ -1538,7 +1530,6 @@ static void lib_override_library_main_resync_on_library_indirect_level( (!ID_IS_LINKED(id) && library_indirect_level != 0)) { continue; } - Library *library = id->lib; int level = 0; /* In complex non-supported cases, with several different override hierarchies sharing @@ -1550,21 +1541,12 @@ static void lib_override_library_main_resync_on_library_indirect_level( id = lib_override_library_main_resync_find_root_recurse(id, &level); id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id)); - BLI_assert(id->lib == library); do_continue = true; - CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, library); + CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, id->lib); const bool success = BKE_lib_override_library_resync( bmain, scene, view_layer, id, override_resync_residual_storage, false, false, reports); CLOG_INFO(&LOG, 2, "\tSuccess: %d", success); - if (success) { - reports->count.resynced_lib_overrides++; - if (library_indirect_level > 0 && - BLI_linklist_index(reports->resynced_lib_overrides_libraries, library) < 0) { - BLI_linklist_prepend(&reports->resynced_lib_overrides_libraries, library); - reports->resynced_lib_overrides_libraries_count++; - } - } break; } FOREACH_MAIN_LISTBASE_ID_END; @@ -1574,10 +1556,6 @@ static void lib_override_library_main_resync_on_library_indirect_level( } FOREACH_MAIN_LISTBASE_END; } - - if (do_reports_recursive_resync_timing) { - reports->duration.lib_overrides_recursive_resync += PIL_check_seconds_timer() - init_time; - } } static int lib_override_sort_libraries_func(LibraryIDLinkCallbackData *cb_data) @@ -1655,7 +1633,7 @@ static int lib_override_libraries_index_define(Main *bmain) void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *view_layer, - BlendFileReadReport *reports) + ReportList *reports) { /* We use a specific collection to gather/store all 'orphaned' override collections and objects * generated by re-sync-process. This avoids putting them in scene's master collection. */ diff --git a/source/blender/blenloader/BLO_read_write.h b/source/blender/blenloader/BLO_read_write.h index 86c7c367816..ea0532d884b 100644 --- a/source/blender/blenloader/BLO_read_write.h +++ b/source/blender/blenloader/BLO_read_write.h @@ -54,7 +54,6 @@ typedef struct BlendExpander BlendExpander; typedef struct BlendLibReader BlendLibReader; typedef struct BlendWriter BlendWriter; -struct BlendFileReadReport; struct Main; struct ReportList; @@ -217,7 +216,7 @@ bool BLO_read_requires_endian_switch(BlendDataReader *reader); bool BLO_read_data_is_undo(BlendDataReader *reader); void BLO_read_data_globmap_add(BlendDataReader *reader, void *oldaddr, void *newaddr); void BLO_read_glob_list(BlendDataReader *reader, struct ListBase *list); -struct BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader); +struct ReportList *BLO_read_data_reports(BlendDataReader *reader); /* Blend Read Lib API * =================== @@ -234,7 +233,7 @@ ID *BLO_read_get_new_id_address(BlendLibReader *reader, struct Library *lib, str /* Misc. */ bool BLO_read_lib_is_undo(BlendLibReader *reader); struct Main *BLO_read_lib_get_main(BlendLibReader *reader); -struct BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader); +struct ReportList *BLO_read_lib_reports(BlendLibReader *reader); /* Blend Expand API * =================== @@ -251,10 +250,8 @@ void BLO_expand_id(BlendExpander *expander, struct ID *id); * =================== */ -void BLO_reportf_wrap(struct BlendFileReadReport *reports, - ReportType type, - const char *format, - ...) ATTR_PRINTF_FORMAT(3, 4); +void BLO_reportf_wrap(struct ReportList *reports, ReportType type, const char *format, ...) + ATTR_PRINTF_FORMAT(3, 4); #ifdef __cplusplus } diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 62c3cb67091..89db216aada 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -89,35 +89,6 @@ struct BlendFileReadParams { int undo_direction; /* eUndoStepDir */ }; -typedef struct BlendFileReadReport { - /* General reports handling. */ - struct ReportList *reports; - - /* Timing informations .*/ - struct { - double whole; - double libraries; - double lib_overrides; - double lib_overrides_resync; - double lib_overrides_recursive_resync; - } duration; - - /* Count informations. */ - struct { - /* Some numbers of IDs that ended up in a specific state, or required some specific process - * during this file read. */ - int missing_libraries; - int missing_linked_id; - /* Number of root override IDs that were resynced. */ - int resynced_lib_overrides; - } count; - - /* Number of libraries which had overrides that needed to be resynced, and a single linked list - * of those. */ - int resynced_lib_overrides_libraries_count; - struct LinkNode *resynced_lib_overrides_libraries; -} BlendFileReadReport; - /* skip reading some data-block types (may want to skip screen data too). */ typedef enum eBLOReadSkip { BLO_READ_SKIP_NONE = 0, @@ -130,7 +101,7 @@ typedef enum eBLOReadSkip { BlendFileData *BLO_read_from_file(const char *filepath, eBLOReadSkip skip_flags, - struct BlendFileReadReport *reports); + struct ReportList *reports); BlendFileData *BLO_read_from_memory(const void *mem, int memsize, eBLOReadSkip skip_flags, diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 7131d8b887d..19033ba9bf1 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -366,12 +366,12 @@ void BLO_blendhandle_close(BlendHandle *bh) */ BlendFileData *BLO_read_from_file(const char *filepath, eBLOReadSkip skip_flags, - BlendFileReadReport *reports) + ReportList *reports) { BlendFileData *bfd = NULL; FileData *fd; - fd = blo_filedata_from_file(filepath, reports->reports); + fd = blo_filedata_from_file(filepath, reports); if (fd) { fd->reports = reports; fd->skip_flags = skip_flags; @@ -401,7 +401,7 @@ BlendFileData *BLO_read_from_memory(const void *mem, fd = blo_filedata_from_memory(mem, memsize, reports); if (fd) { - fd->reports = &(struct BlendFileReadReport){.reports = reports}; + fd->reports = reports; fd->skip_flags = skip_flags; bfd = blo_read_file_internal(fd, ""); blo_filedata_free(fd); @@ -430,7 +430,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, fd = blo_filedata_from_memfile(memfile, params, reports); if (fd) { - fd->reports = &(struct BlendFileReadReport){.reports = reports}; + fd->reports = reports; fd->skip_flags = params->skip_flags; BLI_strncpy(fd->relabase, filename, sizeof(fd->relabase)); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index af214b81d52..47ed4e5c06f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -72,8 +72,6 @@ #include "BLI_mmap.h" #include "BLI_threads.h" -#include "PIL_time.h" - #include "BLT_translation.h" #include "BKE_anim_data.h" @@ -229,7 +227,7 @@ typedef struct BHeadN { * bit kludge but better than doubling up on prints, * we could alternatively have a versions of a report function which forces printing - campbell */ -void BLO_reportf_wrap(BlendFileReadReport *reports, ReportType type, const char *format, ...) +void BLO_reportf_wrap(ReportList *reports, ReportType type, const char *format, ...) { char fixed_buf[1024]; /* should be long enough */ @@ -241,7 +239,7 @@ void BLO_reportf_wrap(BlendFileReadReport *reports, ReportType type, const char fixed_buf[sizeof(fixed_buf) - 1] = '\0'; - BKE_report(reports->reports, type, fixed_buf); + BKE_report(reports, type, fixed_buf); if (G.background == 0) { printf("%s: %s\n", BKE_report_type_str(type), fixed_buf); @@ -4208,7 +4206,6 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) } if ((fd->skip_flags & BLO_READ_SKIP_DATA) == 0) { - fd->reports->duration.libraries = PIL_check_seconds_timer(); read_libraries(fd, &mainlist); blo_join_main(&mainlist); @@ -4216,8 +4213,6 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) lib_link_all(fd, bfd->main); after_liblink_merged_bmain_process(bfd->main); - fd->reports->duration.libraries = PIL_check_seconds_timer() - fd->reports->duration.libraries; - /* Skip in undo case. */ if (fd->memfile == NULL) { /* Note that we can't recompute user-counts at this point in undo case, we play too much with @@ -4233,7 +4228,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) blo_split_main(&mainlist, bfd->main); LISTBASE_FOREACH (Main *, mainvar, &mainlist) { BLI_assert(mainvar->versionfile != 0); - do_versions_after_linking(mainvar, fd->reports->reports); + do_versions_after_linking(mainvar, fd->reports); } blo_join_main(&mainlist); @@ -4254,13 +4249,8 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) * we can re-generate overrides from their references. */ if (fd->memfile == NULL) { /* Do not apply in undo case! */ - fd->reports->duration.lib_overrides = PIL_check_seconds_timer(); - - BKE_lib_override_library_main_validate(bfd->main, fd->reports->reports); + BKE_lib_override_library_main_validate(bfd->main, fd->reports); BKE_lib_override_library_main_update(bfd->main); - - fd->reports->duration.lib_overrides = PIL_check_seconds_timer() - - fd->reports->duration.lib_overrides; } BKE_collections_after_lib_link(bfd->main); @@ -5216,7 +5206,7 @@ static void library_link_end(Main *mainl, * or they will go again through do_versions - bad, very bad! */ split_main_newid(mainvar, main_newid); - do_versions_after_linking(main_newid, (*fd)->reports->reports); + do_versions_after_linking(main_newid, (*fd)->reports); add_main_to_main(mainvar, main_newid); } @@ -5350,7 +5340,7 @@ static void read_library_linked_id( id->name + 2, mainvar->curlib->filepath_abs, library_parent_filepath(mainvar->curlib)); - basefd->reports->count.missing_linked_id++; + basefd->library_id_missing_count++; /* Generate a placeholder for this ID (simplified version of read_libblock actually...). */ if (r_id) { @@ -5454,7 +5444,7 @@ static FileData *read_library_file_data(FileData *basefd, TIP_("Read packed library: '%s', parent '%s'"), mainptr->curlib->filepath, library_parent_filepath(mainptr->curlib)); - fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports->reports); + fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports); /* Needed for library_append and read_libraries. */ BLI_strncpy(fd->relabase, mainptr->curlib->filepath_abs, sizeof(fd->relabase)); @@ -5467,7 +5457,7 @@ static FileData *read_library_file_data(FileData *basefd, mainptr->curlib->filepath_abs, mainptr->curlib->filepath, library_parent_filepath(mainptr->curlib)); - fd = blo_filedata_from_file(mainptr->curlib->filepath_abs, basefd->reports->reports); + fd = blo_filedata_from_file(mainptr->curlib->filepath_abs, basefd->reports); } if (fd) { @@ -5505,7 +5495,7 @@ static FileData *read_library_file_data(FileData *basefd, if (fd == NULL) { BLO_reportf_wrap( basefd->reports, RPT_INFO, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath_abs); - basefd->reports->count.missing_libraries++; + basefd->library_file_missing_count++; } return fd; @@ -5599,6 +5589,15 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) mainptr->curlib->filedata = NULL; } BKE_main_free(main_newid); + + if (basefd->library_file_missing_count != 0 || basefd->library_id_missing_count != 0) { + BKE_reportf(basefd->reports, + RPT_WARNING, + "LIB: %d libraries and %d linked data-blocks are missing, please check the " + "Info and Outliner editors for details", + basefd->library_file_missing_count, + basefd->library_id_missing_count); + } } void *BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address) @@ -5786,7 +5785,7 @@ void BLO_read_glob_list(BlendDataReader *reader, ListBase *list) link_glob_list(reader->fd, list); } -BlendFileReadReport *BLO_read_data_reports(BlendDataReader *reader) +ReportList *BLO_read_data_reports(BlendDataReader *reader) { return reader->fd->reports; } @@ -5801,7 +5800,7 @@ Main *BLO_read_lib_get_main(BlendLibReader *reader) return reader->main; } -BlendFileReadReport *BLO_read_lib_reports(BlendLibReader *reader) +ReportList *BLO_read_lib_reports(BlendLibReader *reader) { return reader->fd->reports; } diff --git a/source/blender/blenloader/intern/readfile.h b/source/blender/blenloader/intern/readfile.h index 0fc71760b44..d1d4e0b3256 100644 --- a/source/blender/blenloader/intern/readfile.h +++ b/source/blender/blenloader/intern/readfile.h @@ -145,7 +145,11 @@ typedef struct FileData { ListBase *old_mainlist; struct IDNameLib_Map *old_idmap; - struct BlendFileReadReport *reports; + struct ReportList *reports; + /* Counters for amount of missing libraries, and missing IDs in libraries. + * Used to generate a synthetic report in the UI. */ + int library_file_missing_count; + int library_id_missing_count; } FileData; #define SIZEOFBLENDERHEADER 12 diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 0059074c8ad..bf8f7eeca5c 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1912,9 +1912,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) FOREACH_NODETREE_END; if (error & NTREE_DOVERSION_NEED_OUTPUT) { - BKE_report(fd->reports != NULL ? fd->reports->reports : NULL, - RPT_ERROR, - "Eevee material conversion problem. Error in console"); + BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); printf( "You need to connect Principled and Eevee Specular shader nodes to new material " "output " @@ -1922,9 +1920,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } if (error & NTREE_DOVERSION_TRANSPARENCY_EMISSION) { - BKE_report(fd->reports != NULL ? fd->reports->reports : NULL, - RPT_ERROR, - "Eevee material conversion problem. Error in console"); + BKE_report(fd->reports, RPT_ERROR, "Eevee material conversion problem. Error in console"); printf( "You need to combine transparency and emission shaders to the converted Principled " "shader nodes.\n"); diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.cc b/source/blender/blenloader/tests/blendfile_loading_base_test.cc index e93348b2158..280a4b42b36 100644 --- a/source/blender/blenloader/tests/blendfile_loading_base_test.cc +++ b/source/blender/blenloader/tests/blendfile_loading_base_test.cc @@ -123,8 +123,7 @@ bool BlendfileLoadingBaseTest::blendfile_load(const char *filepath) char abspath[FILENAME_MAX]; BLI_path_join(abspath, sizeof(abspath), test_assets_dir.c_str(), filepath, NULL); - BlendFileReadReport bf_reports = {NULL}; - bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, &bf_reports); + bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, nullptr /* reports */); if (bfile == nullptr) { ADD_FAILURE() << "Unable to load file '" << filepath << "' from test assets dir '" << test_assets_dir << "'"; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index d59d04b6ac2..f809bb13b42 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -86,8 +86,6 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "../../blender/blenloader/BLO_readfile.h" - #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -932,14 +930,8 @@ static void id_override_library_resync_fn(bContext *C, te->store_elem->id->tag |= LIB_TAG_DOIT; } - BKE_lib_override_library_resync(bmain, - scene, - CTX_data_view_layer(C), - id_root, - NULL, - do_hierarchy_enforce, - true, - &(struct BlendFileReadReport){.reports = reports}); + BKE_lib_override_library_resync( + bmain, scene, CTX_data_view_layer(C), id_root, NULL, do_hierarchy_enforce, true, reports); WM_event_add_notifier(C, NC_WINDOW, NULL); } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 57d03674e2f..0aff2c00644 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -52,15 +52,12 @@ #include "BLI_blenlib.h" #include "BLI_fileops_types.h" #include "BLI_linklist.h" -#include "BLI_math.h" #include "BLI_system.h" #include "BLI_threads.h" #include "BLI_timer.h" #include "BLI_utildefines.h" #include BLI_SYSTEM_PID_H -#include "PIL_time.h" - #include "BLT_translation.h" #include "BLF_api.h" @@ -736,97 +733,6 @@ static void wm_file_read_post(bContext *C, /** \name Read Main Blend-File API * \{ */ -static void file_read_reports_finalize(BlendFileReadReport *bf_reports) -{ - double duration_whole_minutes, duration_whole_seconds; - double duration_libraries_minutes, duration_libraries_seconds; - double duration_lib_override_minutes, duration_lib_override_seconds; - double duration_lib_override_resync_minutes, duration_lib_override_resync_seconds; - double duration_lib_override_recursive_resync_minutes, - duration_lib_override_recursive_resync_seconds; - - BLI_math_time_seconds_decompose(bf_reports->duration.whole, - NULL, - NULL, - &duration_whole_minutes, - &duration_whole_seconds, - NULL); - BLI_math_time_seconds_decompose(bf_reports->duration.libraries, - NULL, - NULL, - &duration_libraries_minutes, - &duration_libraries_seconds, - NULL); - BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides, - NULL, - NULL, - &duration_lib_override_minutes, - &duration_lib_override_seconds, - NULL); - BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides_resync, - NULL, - NULL, - &duration_lib_override_resync_minutes, - &duration_lib_override_resync_seconds, - NULL); - BLI_math_time_seconds_decompose(bf_reports->duration.lib_overrides_recursive_resync, - NULL, - NULL, - &duration_lib_override_recursive_resync_minutes, - &duration_lib_override_recursive_resync_seconds, - NULL); - - CLOG_INFO( - &LOG, 0, "Blender file read in %.0fm%.2fs", duration_whole_minutes, duration_whole_seconds); - CLOG_INFO(&LOG, - 0, - " * Loading libraries: %.0fm%.2fs", - duration_libraries_minutes, - duration_libraries_seconds); - CLOG_INFO(&LOG, - 0, - " * Applying overrides: %.0fm%.2fs", - duration_lib_override_minutes, - duration_lib_override_seconds); - CLOG_INFO(&LOG, - 0, - " * Resyncing overrides: %.0fm%.2fs (%d root overrides), including recursive " - "resyncs: %.0fm%.2fs)", - duration_lib_override_resync_minutes, - duration_lib_override_resync_seconds, - bf_reports->count.resynced_lib_overrides, - duration_lib_override_recursive_resync_minutes, - duration_lib_override_recursive_resync_seconds); - if (bf_reports->resynced_lib_overrides_libraries_count != 0) { - for (LinkNode *node_lib = bf_reports->resynced_lib_overrides_libraries; node_lib != NULL; - node_lib = node_lib->next) { - Library *library = node_lib->link; - BKE_reportf( - bf_reports->reports, RPT_INFO, "Library %s needs overrides resync.", library->filepath); - } - } - if (bf_reports->count.missing_libraries != 0 || bf_reports->count.missing_linked_id != 0) { - BKE_reportf(bf_reports->reports, - RPT_WARNING, - "%d libraries and %d linked data-blocks are missing, please check the " - "Info and Outliner editors for details", - bf_reports->count.missing_libraries, - bf_reports->count.missing_linked_id); - } - if (bf_reports->resynced_lib_overrides_libraries_count != 0) { - BKE_reportf(bf_reports->reports, - RPT_WARNING, - "%d libraries have overrides needing resync (auto resynced in %.0fm%.2fs), " - "please check the Info editor for details", - bf_reports->resynced_lib_overrides_libraries_count, - duration_lib_override_recursive_resync_minutes, - duration_lib_override_recursive_resync_seconds); - } - - BLI_linklist_free(bf_reports->resynced_lib_overrides_libraries, NULL); - bf_reports->resynced_lib_overrides_libraries = NULL; -} - bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) { /* assume automated tasks with background, don't write recent file list */ @@ -857,9 +763,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) .skip_flags = BLO_READ_SKIP_USERDEF, }; - BlendFileReadReport bf_reports = {.reports = reports, - .duration.whole = PIL_check_seconds_timer()}; - struct BlendFileData *bfd = BKE_blendfile_read(filepath, ¶ms, &bf_reports); + struct BlendFileData *bfd = BKE_blendfile_read(filepath, ¶ms, reports); if (bfd != NULL) { wm_file_read_pre(C, use_data, use_userdef); @@ -872,7 +776,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) * need to re-enable it here else drivers + registered scripts wont work. */ const int G_f_orig = G.f; - BKE_blendfile_read_setup(C, bfd, ¶ms, &bf_reports); + BKE_blendfile_read_setup(C, bfd, ¶ms, reports); if (G.f != G_f_orig) { const int flags_keep = G_FLAG_ALL_RUNTIME; @@ -903,9 +807,6 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) wm_file_read_post(C, false, false, use_data, use_userdef, false); - bf_reports.duration.whole = PIL_check_seconds_timer() - bf_reports.duration.whole; - file_read_reports_finalize(&bf_reports); - success = true; } } @@ -1186,15 +1087,10 @@ void wm_homefile_read(bContext *C, .skip_flags = skip_flags | BLO_READ_SKIP_USERDEF, }; - struct BlendFileData *bfd = BKE_blendfile_read( - filepath_startup, ¶ms, &(BlendFileReadReport){NULL}); + struct BlendFileData *bfd = BKE_blendfile_read(filepath_startup, ¶ms, NULL); if (bfd != NULL) { - BKE_blendfile_read_setup_ex(C, - bfd, - ¶ms, - &(BlendFileReadReport){NULL}, - update_defaults && use_data, - app_template); + BKE_blendfile_read_setup_ex( + C, bfd, ¶ms, NULL, update_defaults && use_data, app_template); success = true; } } @@ -1224,7 +1120,7 @@ void wm_homefile_read(bContext *C, struct BlendFileData *bfd = BKE_blendfile_read_from_memory( datatoc_startup_blend, datatoc_startup_blend_size, ¶ms, NULL); if (bfd != NULL) { - BKE_blendfile_read_setup_ex(C, bfd, ¶ms, &(BlendFileReadReport){NULL}, true, NULL); + BKE_blendfile_read_setup_ex(C, bfd, ¶ms, NULL, true, NULL); success = true; } -- cgit v1.2.3