WindowManager: Keep track or the source library when appending.

Keep track of the source library allowing other parts of the code to
to make better decisions. This is needed to localize external files.

In this case the file paths are updated when `making local`.
But we should decide based on the source library if we want to
copy the file relative to the new blend file. See D12423.

Reviewed By: mont29, Severin

Differential Revision: https://developer.blender.org/D12765
This commit is contained in:
Jeroen Bakker 2021-10-12 09:49:06 +02:00 committed by Jeroen Bakker
parent 690382bef5
commit 29e5dc1b19
Notes: blender-bot 2023-02-13 22:37:44 +01:00
Referenced by issue #92153, Geometry Nodes: crash with the capture Attribute node
Referenced by issue #91252, As a user I want external files to be localized when appending an asset so they are part of the project I'm working on.
1 changed files with 3 additions and 0 deletions

View File

@ -177,6 +177,7 @@ typedef struct WMLinkAppendDataItem {
char append_tag;
ID *new_id;
Library *source_library;
void *customdata;
} WMLinkAppendDataItem;
@ -622,6 +623,7 @@ static int foreach_libblock_append_callback(LibraryIDLinkCallbackData *cb_data)
if (item == NULL) {
item = wm_link_append_data_item_add(data->lapp_data, id->name, GS(id->name), NULL);
item->new_id = id;
item->source_library = id->lib;
/* Since we did not have an item for that ID yet, we now user did not selected it explicitly,
* it was rather linked indirectly. This info is important for instantiation of collections. */
item->append_tag |= WM_APPEND_TAG_INDIRECT;
@ -1004,6 +1006,7 @@ static void wm_link_do(WMLinkAppendData *lapp_data,
* This avoids trying to link same item with other libraries to come. */
BLI_bitmap_set_all(item->libraries, false, lapp_data->num_libraries);
item->new_id = new_id;
item->source_library = new_id->lib;
}
}