From 946c70e6a7892985289bf8dfaead8512d33eba79 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 3 Feb 2022 15:34:56 +0100 Subject: Fix (unreported) broken do_version of hidden layers from pre-2.8 files. `BKE_collection_object_add` ensures given object is added to an editable collection, and not e.g. a linked or override one. However, some processes like do_version manipulate collections also from libraries, i.e. linked collections, in those cases we need a version of the code that unconditionnally adds the given object to the given colleciton. --- source/blender/blenkernel/intern/collection.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern/collection.c') diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index e6ce4eb9440..79f40c1c888 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1094,14 +1094,12 @@ static bool collection_object_remove(Main *bmain, return true; } -bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) +bool BKE_collection_object_add_notest(Main *bmain, Collection *collection, Object *ob) { - if (ELEM(NULL, collection, ob)) { + if (ob == NULL) { return false; } - collection = collection_parent_editable_find_recursive(collection); - /* Only case where this pointer can be NULL is when scene itself is linked, this case should * never be reached. */ BLI_assert(collection != NULL); @@ -1122,6 +1120,17 @@ bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) return true; } +bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob) +{ + if (collection == NULL) { + return false; + } + + collection = collection_parent_editable_find_recursive(collection); + + return BKE_collection_object_add_notest(bmain, collection, ob); +} + void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, Object *ob_dst) { bool is_instantiated = false; -- cgit v1.2.3