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 12:41:23 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-11-30 12:41:23 +0300
commitc12d8a72cef557c0d9c76e78c3754e3009e74efd (patch)
treede35215da19c383d3bc73bf9ae7c8096210b1431
parente7ae9f493aaa004caf3627489752139f177a807b (diff)
BPath traversing: allow skipping weak library references
Add flag to `BKE_bpath_traverse_id()` and friends to skip weak references (see below). This makes a distinction between "this blend file depends on that file" and "this blend file references that file, but doesn't directly use its data". This distinction is for the Asset Bundle install operator, which refuses to copy the blend file when it's not self-contained. Weak references are those that are not directly used by the blend file, but are still present to allow path rewriting. For example, when an Asset is loaded its originating blend file is saved in `ID::library_weak_reference`; this reference is purely for deduplication purposes, and not for actually loading any data. Reviewed by: mont29, brecht Differential Revision: https://developer.blender.org/D13412
-rw-r--r--source/blender/blenkernel/BKE_bpath.h6
-rw-r--r--source/blender/blenkernel/intern/bpath.c3
-rw-r--r--source/blender/editors/asset/intern/asset_ops.cc5
3 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_bpath.h b/source/blender/blenkernel/BKE_bpath.h
index 3ec5409ca7f..65ccfaebd35 100644
--- a/source/blender/blenkernel/BKE_bpath.h
+++ b/source/blender/blenkernel/BKE_bpath.h
@@ -70,6 +70,12 @@ enum {
BKE_BPATH_TRAVERSE_SKIP_MULTIFILE = (1 << 3),
/* reload data (when the path is edited) */
BKE_BPATH_TRAVERSE_RELOAD_EDITED = (1 << 4),
+ /* Skip weak reference paths. Those paths are typically 'nice to have' extra information, but are
+ * not used as actual source of data by the current .blend file.
+ *
+ * NOTE: Currently this only concerns the weak reference to a library file stored in
+ * `ID::library_weak_reference`. */
+ BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES = (1 << 5),
};
/* high level funcs */
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index 9ce58d8129b..7a7f46a8a2d 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -586,7 +586,8 @@ void BKE_bpath_traverse_id(
return;
}
- if (id->library_weak_reference != NULL) {
+ if (id->library_weak_reference != NULL &&
+ (flag & BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES) == 0) {
rewrite_path_fixed(
id->library_weak_reference->library_filepath, visit_cb, absbase, bpath_user_data);
}
diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc
index 9d03f6030b5..5ff82fcb0c0 100644
--- a/source/blender/editors/asset/intern/asset_ops.cc
+++ b/source/blender/editors/asset/intern/asset_ops.cc
@@ -912,8 +912,9 @@ static bool has_external_files(Main *bmain, struct ReportList *reports)
BKE_bpath_traverse_main(
bmain,
&external_file_check_callback,
- BKE_BPATH_TRAVERSE_SKIP_PACKED /* Packed files are fine. */
- | BKE_BPATH_TRAVERSE_SKIP_MULTIFILE /* Only report multifiles once, it's enough. */,
+ BKE_BPATH_TRAVERSE_SKIP_PACKED /* Packed files are fine. */
+ | 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;
}