diff options
Diffstat (limited to 'source/blender/windowmanager/intern')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files_link.c | 16 |
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; } |