diff options
author | Hans Goudey <h.goudey@me.com> | 2020-11-16 18:59:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-11-16 18:59:49 +0300 |
commit | c645da98d8727e636c14383f4c10706c6cc5ead2 (patch) | |
tree | ffd591f67c90e375b9336c3fdcae32d0bf8ad315 /source/blender/blenkernel/intern/collection.c | |
parent | 75af3165ca6bf4cbb54a9f63e89cc10c90cd982c (diff) |
Fix T82439: Crash moving collections between scenes
The original code for viewlayer collection flag syncing across moves
from D9158 didn't consider the case where the collection could no longer
be found in its original view layer (moving a collections betwen scenes).
The fix is to just check if the collection starts in the same scene as
it will be moved to before trying to do the flag syncing. I thought about
this for a while and tried a couple other solutions, but I couldn't come
up with a proper way to support syncing the layer collection flags across
scenes without making too many changes.
Differential Revision: https://developer.blender.org/D9568
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 0ed6f94ce79..e6620ea10dc 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1689,15 +1689,23 @@ bool BKE_collection_move(Main *bmain, } /* Make sure we store the flag of the layer collections before we remove and re-create them. - * Otherwise they will get lost and everything will be copied from the new parent collection. */ + * Otherwise they will get lost and everything will be copied from the new parent collection. + * Don't use flag syncing when moving a collection to a different scene, as it no longer exists + * in the same view layers anyway. */ + const bool do_flag_sync = BKE_scene_find_from_collection(bmain, to_parent) == + BKE_scene_find_from_collection(bmain, collection); ListBase layer_flags; - layer_collection_flags_store(bmain, collection, &layer_flags); + if (do_flag_sync) { + layer_collection_flags_store(bmain, collection, &layer_flags); + } /* Create and remove layer collections. */ BKE_main_collection_sync(bmain); /* Restore the original layer collection flags. */ - layer_collection_flags_restore(&layer_flags, collection); + if (do_flag_sync) { + layer_collection_flags_restore(&layer_flags, collection); + } /* We need to sync it again to pass the correct flags to the collections objects. */ BKE_main_collection_sync(bmain); |