mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix: Collection Import: Incomplete 'make linked' on imported data.
`BKE_main_merge_as_archive_library` would not properly propagate the new library to embedded IDs, and would miss adding the direct/indirect tag to all IDs. Also enable the `link_after_import` related disabled test. Pull Request: https://projects.blender.org/blender/blender/pulls/162354
This commit is contained in:
parent
a12f02216d
commit
56f45c663b
3 changed files with 9 additions and 7 deletions
|
|
@ -326,8 +326,7 @@ void id_lib_extern(ID *id, const bool enforce_fix)
|
|||
{
|
||||
if (id && ID_IS_LINKED(id)) {
|
||||
#ifndef NDEBUG
|
||||
/* Disabled until issues in Collection Import's external packed linked data is fixed. */
|
||||
if (0 && !enforce_fix) {
|
||||
if (!enforce_fix) {
|
||||
const eID_Tag linked_tags = eID_Tag(id->tag & (ID_TAG_EXTERN | ID_TAG_INDIRECT));
|
||||
BLI_assert_msg(
|
||||
linked_tags != (ID_TAG_EXTERN | ID_TAG_INDIRECT),
|
||||
|
|
@ -353,8 +352,7 @@ void id_lib_indirect(ID *id, const bool enforce_fix)
|
|||
{
|
||||
if (id && ID_IS_LINKED(id)) {
|
||||
#ifndef NDEBUG
|
||||
/* Disabled until issues in Collection Import's external packed linked data is fixed. */
|
||||
if (0 && !enforce_fix) {
|
||||
if (!enforce_fix) {
|
||||
const eID_Tag linked_tags = eID_Tag(id->tag & (ID_TAG_EXTERN | ID_TAG_INDIRECT));
|
||||
BLI_assert_msg(
|
||||
linked_tags != (ID_TAG_EXTERN | ID_TAG_INDIRECT),
|
||||
|
|
|
|||
|
|
@ -601,20 +601,25 @@ void BKE_main_merge_as_archive_library(Main &bmain_dst,
|
|||
BKE_libblock_management_main_remove(&bmain_src, id);
|
||||
id->lib = &dst_external_library;
|
||||
|
||||
/* Consider these IDs as linked and packed. */
|
||||
/* Consider these IDs as directly linked and packed. */
|
||||
id->flag |= ID_FLAG_LINKED_AND_PACKED;
|
||||
|
||||
/* Need to tag embedded IDs as well. */
|
||||
bNodeTree *ntree = bke::node_tree_from_id(id);
|
||||
if (ntree != nullptr) {
|
||||
ntree->id.lib = &dst_external_library;
|
||||
ntree->id.flag |= ID_FLAG_LINKED_AND_PACKED;
|
||||
}
|
||||
if (GS(id->name) == ID_SCE) {
|
||||
Collection *master_collection = (id_cast<Scene *>(id))->master_collection;
|
||||
if (master_collection != nullptr) {
|
||||
master_collection->id.lib = &dst_external_library;
|
||||
master_collection->id.flag |= ID_FLAG_LINKED_AND_PACKED;
|
||||
}
|
||||
}
|
||||
|
||||
/* Needs to be done after setting library for embedded IDs above too. */
|
||||
id_lib_extern(id, true);
|
||||
}
|
||||
|
||||
/* Add all IDs into the destination Main under the external library. */
|
||||
|
|
|
|||
|
|
@ -193,8 +193,7 @@ class TestCollectionImport(CollectionIOTestBase):
|
|||
self.assertEqual(len(bpy.data.collections[coll_C].all_objects), 0)
|
||||
# TODO: Library validation once scenario is supported
|
||||
|
||||
# Disabled: Produces asserts during the save_mainfile call
|
||||
def __disabled_test_link_after_import(self):
|
||||
def link_after_import(self):
|
||||
# Validate that a remote collection, which has an importer, is able to
|
||||
# be linked in with all its contents.
|
||||
self.reset_blender()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue