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:
authorHans Goudey <h.goudey@me.com>2020-12-11 21:15:51 +0300
committerHans Goudey <h.goudey@me.com>2020-12-11 21:15:51 +0300
commit97651f428b6ae6901cbacd9805616fe96052bc9b (patch)
tree6ff53bb2703cb235e9031091b9185ce5fcbeb31a /source/blender/blenkernel
parentb73ed882c0d0dd3b4fed652e06240b0d705f3f80 (diff)
Fix T83050: Crash dragging shared collection to master collection
The flag syncing code expects to find collection flags in same view layer before and after the move, it even has an assert for it. However, there is one case where this doesn't happen, when dragging a collection that exists in two scenes to the master collection. This commit removes this assert, frees the temporary flag structs separately, and updates some comments with this information. There is more detail in the adjusted comment. Differential Revision: https://developer.blender.org/D9785
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/collection.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 5eec788255d..b86b59066d6 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -1773,6 +1773,15 @@ static void layer_collection_flags_store(Main *bmain,
}
}
+static void layer_collection_flags_free_recursive(LayerCollectionFlag *flag)
+{
+ LISTBASE_FOREACH (LayerCollectionFlag *, child, &flag->children) {
+ layer_collection_flags_free_recursive(child);
+ }
+
+ BLI_freelistN(&flag->children);
+}
+
static void layer_collection_flags_restore_recursive(LayerCollection *layer_collection,
LayerCollectionFlag *flag)
{
@@ -1788,7 +1797,6 @@ static void layer_collection_flags_restore_recursive(LayerCollection *layer_coll
child_flag = child_flag->next;
}
- BLI_freelistN(&flag->children);
/* We treat exclude as a special case.
*
@@ -1814,10 +1822,15 @@ static void layer_collection_flags_restore(ListBase *flags, const Collection *co
LayerCollection *layer_collection = BKE_layer_collection_first_from_scene_collection(
view_layer, collection);
- /* The flags should only be added if the collection is in the view layer. */
- BLI_assert(layer_collection != NULL);
-
- layer_collection_flags_restore_recursive(layer_collection, flag);
+ /* Check that the collection is still in the scene (and therefore its view layers). In most
+ * cases this is true, but if we move a sub-collection shared by several scenes to a collection
+ * local to the target scene, it is effectively removed from every other scene's hierarchy
+ * (e.g. moving into current scene's master collection). Then the other scene's view layers
+ * won't contain a matching layer collection anymore, so there is nothing to restore to. */
+ if (layer_collection != NULL) {
+ layer_collection_flags_restore_recursive(layer_collection, flag);
+ }
+ layer_collection_flags_free_recursive(flag);
}
BLI_freelistN(flags);
@@ -1877,7 +1890,7 @@ bool BKE_collection_move(Main *bmain,
/* Create and remove layer collections. */
BKE_main_collection_sync(bmain);
- /* Restore the original layer collection flags. */
+ /* Restore the original layer collection flags and free their temporary storage. */
if (do_flag_sync) {
layer_collection_flags_restore(&layer_flags, collection);
}