diff options
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 1388146eeb7..675e86b1584 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -314,9 +314,17 @@ static Collection *collection_duplicate_recursive(Main *bmain, Collection *collection_new; bool do_full_process = false; const int object_dupflag = (do_obdata) ? U.dupflag : 0; + const bool is_collection_master = (collection_old->flag & COLLECTION_IS_MASTER) != 0; const bool is_collection_liboverride = ID_IS_OVERRIDE_LIBRARY(collection_old); - if (!do_hierarchy || collection_old->id.newid == NULL) { + if (is_collection_master) { + /* We never duplicate master collections here, but we can still deep-copy their objects and + * collections. */ + BLI_assert(parent == NULL); + collection_new = collection_old; + do_full_process = true; + } + else if (!do_hierarchy || collection_old->id.newid == NULL) { BKE_id_copy(bmain, &collection_old->id, (ID **)&collection_new); /* Copying add one user by default, need to get rid of that one. */ @@ -378,7 +386,7 @@ static Collection *collection_duplicate_recursive(Main *bmain, /* We can loop on collection_old's children, * that list is currently identical the collection_new' children, and won't be changed here. */ - LISTBASE_FOREACH (CollectionChild *, child, &collection_old->children) { + LISTBASE_FOREACH_MUTABLE (CollectionChild *, child, &collection_old->children) { Collection *child_collection_old = child->collection; collection_duplicate_recursive( @@ -422,13 +430,6 @@ Collection *BKE_collection_duplicate(Main *bmain, const bool do_objects, const bool do_obdata) { - /* It's not allowed to copy the master collection. */ - BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) == 0); - BLI_assert((collection->flag & COLLECTION_IS_MASTER) == 0); - if (collection->flag & COLLECTION_IS_MASTER) { - return NULL; - } - if (do_hierarchy) { BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false); BKE_main_id_clear_newpoins(bmain); |