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:
authorBastien Montagne <bastien@blender.org>2021-10-06 12:38:11 +0300
committerBastien Montagne <bastien@blender.org>2021-10-06 12:43:42 +0300
commit9ed19db5392d76bc810afabeb93fcd34a23fd88d (patch)
tree5a2009f6c0223eba7cbd7b826fe2579d7fdb18e7 /source/blender/windowmanager/intern/wm_files_link.c
parentb5ea3d2c09c5df49ed783dabdc83820c55effdd2 (diff)
Fix handling of overrides during append.
Liboverride references need a special handling during append, since those pointers should never be made local, nor reampped to newly localized data. And liboverride references should never be directly made local either, to ensure their liboverride usages remain pointing to linked data and not local one. Issue was reported by the studio, and also probably as part of T91892.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files_link.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index cf3536213d2..12ab10e3a70 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -595,7 +595,10 @@ static void wm_append_loose_data_instantiate(WMLinkAppendData *lapp_data,
static int foreach_libblock_append_callback(LibraryIDLinkCallbackData *cb_data)
{
- if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_INTERNAL | IDWALK_CB_LOOPBACK)) {
+ /* NOTE: It is important to also skip liboverride references here, as those should never be made
+ * local. */
+ if (cb_data->cb_flag & (IDWALK_CB_EMBEDDED | IDWALK_CB_INTERNAL | IDWALK_CB_LOOPBACK |
+ IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) {
return IDWALK_RET_NOP;
}
@@ -652,7 +655,8 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
LinkNode *itemlink;
- /* Generate a mapping between newly linked IDs and their items. */
+ /* Generate a mapping between newly linked IDs and their items, and tag linked IDs used as
+ * liboverride references as already existing. */
lapp_data->new_id_to_item = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
for (itemlink = lapp_data->items.list; itemlink; itemlink = itemlink->next) {
WMLinkAppendDataItem *item = itemlink->link;
@@ -661,6 +665,13 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
continue;
}
BLI_ghash_insert(lapp_data->new_id_to_item, id, item);
+
+ /* This ensures that if a liboverride reference is also linked/used by some other appended
+ * data, it gets a local copy instead of being made directly local, so that the liboverride
+ * references remain valid (i.e. linked data). */
+ if (ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
+ id->override_library->reference->tag |= LIB_TAG_PRE_EXISTING;
+ }
}
lapp_data->library_weak_reference_mapping = BKE_main_library_weak_reference_create(bmain);
@@ -704,7 +715,6 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
item->append_action = WM_APPEND_ACT_COPY_LOCAL;
}
else {
- /* In future we could search for already existing matching local ID etc. */
CLOG_INFO(&LOG, 3, "Appended ID '%s' will be made local...", id->name);
item->append_action = WM_APPEND_ACT_MAKE_LOCAL;
}