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-09-23 13:54:23 +0300
committerBastien Montagne <bastien@blender.org>2021-09-23 13:54:23 +0300
commitcb173d05dc3e17f0407ebdeb7d092344242ea4ad (patch)
treece8044958d1c4edab35b1e30362ff41e1b0684c3 /source/blender
parent6f53988e7afbedddc2c442b49622860ebee41bcc (diff)
LibLink Append: Fix 'reused ID' case keeping linked data around.
When we re-use a local ID, we need to delete the matching linked data.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 817947f2161..b61337ec8e4 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -805,6 +805,27 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
BKE_libblock_relink_to_newid_new(bmain, id);
}
+ /* Remove linked IDs when a local existing data has been reused instead. */
+ for (itemlink = lapp_data->items.list; itemlink; itemlink = itemlink->next) {
+ WMLinkAppendDataItem *item = itemlink->link;
+
+ if (item->append_action != WM_APPEND_ACT_REUSE_LOCAL) {
+ continue;
+ }
+
+ ID *id = item->new_id;
+ if (id == NULL) {
+ continue;
+ }
+ BLI_assert(ID_IS_LINKED(id));
+ BLI_assert(id->newid != NULL);
+ BLI_assert((id->tag & LIB_TAG_DOIT) == 0);
+
+ id->tag |= LIB_TAG_DOIT;
+ item->new_id = id->newid;
+ }
+ BKE_id_multi_tagged_delete(bmain);
+
/* Instantiate newly created (duplicated) IDs as needed. */
wm_append_loose_data_instantiate(lapp_data, bmain, scene, view_layer, v3d);