From 2e53f8b4b13186ef9ca04e1979c548ea1acdc763 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 30 Nov 2021 11:24:36 +0100 Subject: Fix T92577: Cannot open shortcut folders on Windows `file.select()` wasn't handling redirects as it should when it also opens directories. This was only uncovered by a change in the keymap. Reviewed By: Bastien Montagne, Harley Acheson Differential Revision: https://developer.blender.org/D13388 --- source/blender/editors/space_file/file_ops.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 15bb7917924..ab11d5c0330 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -211,6 +211,11 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) filelist_setrecursion(sfile->files, params->recursion_level); } } + else if (file->redirection_path) { + BLI_strncpy(params->dir, file->redirection_path, sizeof(params->dir)); + BLI_path_normalize_dir(BKE_main_blendfile_path(bmain), params->dir); + BLI_path_slash_ensure(params->dir); + } else { BLI_path_normalize_dir(BKE_main_blendfile_path(bmain), params->dir); strcat(params->dir, file->relpath); -- cgit v1.2.3 From 4b971bb87c03b99458a65036f2d5c1668690f2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 30 Nov 2021 11:50:38 +0100 Subject: Asset Bundle Copy button: only report each external dependency once The `ASSET_OT_bundle_install` operator only works when the blend file is self-contained. It reports any external dependencies. Before this patch: - every dependency was mentioned, even when it repeated the same filename over and over again, and - multiple dependencies were all mentioned in the error popup, potentially filling the screen. This is now resolved by: - only reporting each external file once, and - referring to the console when there are multiple external dependencies. Reviewed by: severin, dfelinto Differential Revision: https://developer.blender.org/D13413 --- source/blender/editors/asset/intern/asset_ops.cc | 41 ++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc index 5ff82fcb0c0..56d8e61e902 100644 --- a/source/blender/editors/asset/intern/asset_ops.cc +++ b/source/blender/editors/asset/intern/asset_ops.cc @@ -32,6 +32,7 @@ #include "BLI_fileops.h" #include "BLI_fnmatch.h" #include "BLI_path_util.h" +#include "BLI_set.hh" #include "BLI_string_ref.hh" #include "BLI_vector.hh" @@ -882,7 +883,7 @@ static bool set_filepath_for_asset_lib(const Main *bmain, struct wmOperator *op) struct FileCheckCallbackInfo { struct ReportList *reports; - bool external_file_found; + Set external_files; }; static bool external_file_check_callback(void *callback_info_ptr, @@ -890,24 +891,20 @@ static bool external_file_check_callback(void *callback_info_ptr, const char *path_src) { FileCheckCallbackInfo *callback_info = static_cast(callback_info_ptr); - BKE_reportf(callback_info->reports, - RPT_ERROR, - "Unable to install asset bundle, has external dependency \"%s\"", - path_src); - callback_info->external_file_found = true; + callback_info->external_files.add(std::string(path_src)); return false; } /** * Do a check on any external files (.blend, textures, etc.) being used. - * The "Install asset bundle" operator only works on standalone .blend files + * The ASSET_OT_bundle_install operator only works on standalone .blend files * (catalog definition files are fine, though). * * \return true when there are external files, false otherwise. */ static bool has_external_files(Main *bmain, struct ReportList *reports) { - struct FileCheckCallbackInfo callback_info = {reports, false}; + struct FileCheckCallbackInfo callback_info = {reports, Set()}; BKE_bpath_traverse_main( bmain, @@ -916,7 +913,33 @@ static bool has_external_files(Main *bmain, struct ReportList *reports) | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE /* Only report multifiles once, it's enough. */ | BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES /* Only care about actually used files. */, &callback_info); - return callback_info.external_file_found; + + if (callback_info.external_files.is_empty()) { + /* No external dependencies. */ + return false; + } + + if (callback_info.external_files.size() == 1) { + /* Only one external dependency, report it directly. */ + BKE_reportf(callback_info.reports, + RPT_ERROR, + "Unable to copy bundle due to external dependency: \"%s\"", + callback_info.external_files.begin()->c_str()); + return true; + } + + /* Multiple external dependencies, report the aggregate and put details on console. */ + BKE_reportf( + callback_info.reports, + RPT_ERROR, + "Unable to copy bundle due to %ld external dependencies; more details on the console", + callback_info.external_files.size()); + printf("Unable to copy bundle due to %ld external dependencies:\n", + callback_info.external_files.size()); + for (const std::string &path : callback_info.external_files) { + printf(" \"%s\"\n", path.c_str()); + } + return true; } /* -------------------------------------------------------------------- */ -- cgit v1.2.3