Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-06-11 22:13:37 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-06-11 22:13:37 +0300
commit09c32a15d2f9171c2b61220c6ba5cc585f541cb2 (patch)
tree5d31f7d7ff7adc58d8be830ab8e3ce0b90491d12
parent14bd257bb780411ff949129aec4d59ef61423306 (diff)
Fix T64430: Removing objects from sub-collection doesn't update instances of parent collection.
Collections are a tad annoying with all their caching of objects... When we modify content of a children collection, we need to tag DeG for CoW update of all of the ancestors. For now keeping that recursive tagging helper private, but would not be surprised if we found more similar cases and needed to expose it to more code...
-rw-r--r--source/blender/blenkernel/intern/collection.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 03bae118f0f..88ec4f8793f 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -624,6 +624,26 @@ bool BKE_collection_is_empty(Collection *collection)
/********************** Collection Objects *********************/
+static void collection_tag_update_parent_recursive(Main *bmain,
+ Collection *collection,
+ const int flag)
+{
+ if (collection->flag & COLLECTION_IS_MASTER) {
+ return;
+ }
+
+ DEG_id_tag_update_ex(bmain, &collection->id, flag);
+
+ for (CollectionParent *collection_parent = collection->parents.first; collection_parent;
+ collection_parent = collection_parent->next) {
+ if (collection_parent->collection->flag & COLLECTION_IS_MASTER) {
+ /* We don't care about scene/master collection here. */
+ continue;
+ }
+ collection_tag_update_parent_recursive(bmain, collection_parent->collection, flag);
+ }
+}
+
static bool collection_object_add(
Main *bmain, Collection *collection, Object *ob, int flag, const bool add_us)
{
@@ -649,7 +669,7 @@ static bool collection_object_add(
}
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
- DEG_id_tag_update_ex(bmain, &collection->id, ID_RECALC_COPY_ON_WRITE);
+ collection_tag_update_parent_recursive(bmain, collection, ID_RECALC_COPY_ON_WRITE);
}
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
@@ -679,7 +699,7 @@ static bool collection_object_remove(Main *bmain,
id_us_min(&ob->id);
}
- DEG_id_tag_update_ex(bmain, &collection->id, ID_RECALC_COPY_ON_WRITE);
+ collection_tag_update_parent_recursive(bmain, collection, ID_RECALC_COPY_ON_WRITE);
return true;
}