diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_blendfile.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_lib_override.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender_copybuffer.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blender_undo.c | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/blendfile.c | 33 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_override.c | 32 |
6 files changed, 62 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_blendfile.h b/source/blender/blenkernel/BKE_blendfile.h index 429e294a337..3e0a343a766 100644 --- a/source/blender/blenkernel/BKE_blendfile.h +++ b/source/blender/blenkernel/BKE_blendfile.h @@ -25,6 +25,7 @@ extern "C" { struct BlendFileData; struct BlendFileReadParams; +struct BlendFileReadReport; struct ID; struct Main; struct MemFile; @@ -35,7 +36,7 @@ struct bContext; void BKE_blendfile_read_setup_ex(struct bContext *C, struct BlendFileData *bfd, const struct BlendFileReadParams *params, - struct ReportList *reports, + struct BlendFileReadReport *reports, /* Extra args. */ const bool startup_update_defaults, const char *startup_app_template); @@ -43,11 +44,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 ReportList *reports); + struct BlendFileReadReport *reports); struct BlendFileData *BKE_blendfile_read(const char *filepath, const struct BlendFileReadParams *params, - struct ReportList *reports); + struct BlendFileReadReport *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 4dc99e64cf2..3eb0ff44129 100644 --- a/source/blender/blenkernel/BKE_lib_override.h +++ b/source/blender/blenkernel/BKE_lib_override.h @@ -43,6 +43,7 @@ extern "C" { #endif struct Collection; +struct BlendFileReadReport; struct ID; struct IDOverrideLibrary; struct IDOverrideLibraryProperty; @@ -90,11 +91,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 ReportList *reports); + struct BlendFileReadReport *reports); void BKE_lib_override_library_main_resync(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, - struct ReportList *reports); + struct BlendFileReadReport *reports); void BKE_lib_override_library_delete(struct Main *bmain, struct ID *id_root); diff --git a/source/blender/blenkernel/intern/blender_copybuffer.c b/source/blender/blenkernel/intern/blender_copybuffer.c index dfd49a347ca..c8fedc086b8 100644 --- a/source/blender/blenkernel/intern/blender_copybuffer.c +++ b/source/blender/blenkernel/intern/blender_copybuffer.c @@ -87,7 +87,7 @@ bool BKE_copybuffer_read(Main *bmain_dst, ReportList *reports, const uint64_t id_types_mask) { - BlendHandle *bh = BLO_blendhandle_from_file(libname, reports); + BlendHandle *bh = BLO_blendhandle_from_file(libname, &(BlendFileReadReport){.reports = reports}); if (bh == NULL) { /* Error reports will have been made by BLO_blendhandle_from_file(). */ return false; @@ -133,7 +133,7 @@ int BKE_copybuffer_paste(bContext *C, BlendHandle *bh; const int id_tag_extra = 0; - bh = BLO_blendhandle_from_file(libname, reports); + bh = BLO_blendhandle_from_file(libname, &(BlendFileReadReport){.reports = reports}); if (bh == NULL) { /* error reports will have been made by BLO_blendhandle_from_file() */ diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index ba41786c7fd..6f47cd1336e 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -78,9 +78,10 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, if (UNDO_DISK) { const struct BlendFileReadParams params = {0}; - struct BlendFileData *bfd = BKE_blendfile_read(mfu->filename, ¶ms, NULL); + struct BlendFileData *bfd = BKE_blendfile_read( + mfu->filename, ¶ms, &(BlendFileReadReport){NULL}); if (bfd != NULL) { - BKE_blendfile_read_setup(C, bfd, ¶ms, NULL); + BKE_blendfile_read_setup(C, bfd, ¶ms, &(BlendFileReadReport){NULL}); success = true; } } @@ -93,7 +94,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, NULL); + BKE_blendfile_read_setup(C, bfd, ¶ms, &(BlendFileReadReport){NULL}); success = true; } } diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index e335dd4bdcd..9ea1c8fedda 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -36,6 +36,8 @@ #include "BLI_system.h" #include "BLI_utildefines.h" +#include "PIL_time.h" + #include "IMB_colormanagement.h" #include "BKE_addon.h" @@ -136,7 +138,7 @@ static void setup_app_userdef(BlendFileData *bfd) static void setup_app_data(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - ReportList *reports) + BlendFileReadReport *reports) { Main *bmain = G_MAIN; Scene *curscene = NULL; @@ -155,7 +157,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, RPT_WARNING, "Library file, loading empty scene"); + BKE_report(reports->reports, RPT_WARNING, "Library file, loading empty scene"); mode = LOAD_UI_OFF; } else if (G.fileflags & G_FILE_NO_UI) { @@ -396,11 +398,17 @@ 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); } @@ -409,7 +417,7 @@ static void setup_app_data(bContext *C, static void setup_app_blend_file_data(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - ReportList *reports) + BlendFileReadReport *reports) { if ((params->skip_flags & BLO_READ_SKIP_USERDEF) == 0) { setup_app_userdef(bfd); @@ -419,12 +427,12 @@ static void setup_app_blend_file_data(bContext *C, } } -static void handle_subversion_warning(Main *main, ReportList *reports) +static void handle_subversion_warning(Main *main, BlendFileReadReport *reports) { if (main->minversionfile > BLENDER_FILE_VERSION || (main->minversionfile == BLENDER_FILE_VERSION && main->minsubversionfile > BLENDER_FILE_SUBVERSION)) { - BKE_reportf(reports, + BKE_reportf(reports->reports, RPT_ERROR, "File written by newer Blender binary (%d.%d), expect loss of data!", main->minversionfile, @@ -443,7 +451,7 @@ static void handle_subversion_warning(Main *main, ReportList *reports) void BKE_blendfile_read_setup_ex(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - ReportList *reports, + BlendFileReadReport *reports, /* Extra args. */ const bool startup_update_defaults, const char *startup_app_template) @@ -460,7 +468,7 @@ void BKE_blendfile_read_setup_ex(bContext *C, void BKE_blendfile_read_setup(bContext *C, BlendFileData *bfd, const struct BlendFileReadParams *params, - ReportList *reports) + BlendFileReadReport *reports) { BKE_blendfile_read_setup_ex(C, bfd, params, reports, false, NULL); } @@ -470,7 +478,7 @@ void BKE_blendfile_read_setup(bContext *C, */ struct BlendFileData *BKE_blendfile_read(const char *filepath, const struct BlendFileReadParams *params, - ReportList *reports) + BlendFileReadReport *reports) { /* Don't print startup file loading. */ if (params->is_startup == false) { @@ -482,7 +490,7 @@ struct BlendFileData *BKE_blendfile_read(const char *filepath, handle_subversion_warning(bfd->main, reports); } else { - BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath); + BKE_reports_prependf(reports->reports, "Loading '%s' failed: ", filepath); } return bfd; } @@ -559,7 +567,9 @@ 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, reports); + bfd = BLO_read_from_file(filepath, + BLO_READ_SKIP_ALL & ~BLO_READ_SKIP_USERDEF, + &(struct BlendFileReadReport){.reports = reports}); if (bfd) { if (bfd->user) { userdef = bfd->user; @@ -770,7 +780,8 @@ 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, reports); + bfd = BLO_read_from_file( + filepath, BLO_READ_SKIP_USERDEF, &(struct BlendFileReadReport){.reports = 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 c93971e7b11..270d7ca358a 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -52,12 +52,17 @@ #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" @@ -958,7 +963,7 @@ bool BKE_lib_override_library_resync(Main *bmain, Collection *override_resync_residual_storage, const bool do_hierarchy_enforce, const bool do_post_process, - ReportList *reports) + BlendFileReadReport *reports) { BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root)); @@ -1286,7 +1291,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, + BKE_reportf(reports != NULL ? reports->reports : NULL, RPT_WARNING, "During resync of data-block %s, %d obsolete overrides were deleted, that had " "local changes defined by user", @@ -1438,8 +1443,11 @@ static void lib_override_library_main_resync_on_library_indirect_level( ViewLayer *view_layer, Collection *override_resync_residual_storage, const int library_indirect_level, - ReportList *reports) + BlendFileReadReport *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); @@ -1530,6 +1538,7 @@ 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 @@ -1541,12 +1550,21 @@ 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, id->lib); + CLOG_INFO(&LOG, 2, "Resyncing %s (%p)...", id->name, library); 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; @@ -1556,6 +1574,10 @@ 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) @@ -1633,7 +1655,7 @@ static int lib_override_libraries_index_define(Main *bmain) void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *view_layer, - ReportList *reports) + BlendFileReadReport *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. */ |