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

View File

@@ -177,6 +177,7 @@ typedef struct WMLinkAppendDataItem {
char append_tag; char append_tag;
ID *new_id; ID *new_id;
Library *source_library;
void *customdata; void *customdata;
} WMLinkAppendDataItem; } WMLinkAppendDataItem;
@@ -622,6 +623,7 @@ static int foreach_libblock_append_callback(LibraryIDLinkCallbackData *cb_data)
if (item == NULL) { if (item == NULL) {
item = wm_link_append_data_item_add(data->lapp_data, id->name, GS(id->name), NULL); item = wm_link_append_data_item_add(data->lapp_data, id->name, GS(id->name), NULL);
item->new_id = id; 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, /* 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. */ * it was rather linked indirectly. This info is important for instantiation of collections. */
item->append_tag |= WM_APPEND_TAG_INDIRECT; 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. */ * This avoids trying to link same item with other libraries to come. */
BLI_bitmap_set_all(item->libraries, false, lapp_data->num_libraries); BLI_bitmap_set_all(item->libraries, false, lapp_data->num_libraries);
item->new_id = new_id; item->new_id = new_id;
item->source_library = new_id->lib;
} }
} }