Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-11-30 13:50:38 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-11-30 13:50:38 +0300
commit4b971bb87c03b99458a65036f2d5c1668690f2b1 (patch)
treee5f6d68cbeec8e022a9e8a268e80ab9623522f97 /source/blender/editors/asset
parent2e53f8b4b13186ef9ca04e1979c548ea1acdc763 (diff)
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
Diffstat (limited to 'source/blender/editors/asset')
-rw-r--r--source/blender/editors/asset/intern/asset_ops.cc41
1 files changed, 32 insertions, 9 deletions
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<std::string> 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<FileCheckCallbackInfo *>(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<std::string>()};
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;
}
/* -------------------------------------------------------------------- */