diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-01-02 23:19:25 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-01-02 23:19:26 +0300 |
commit | 07de8eff774dbb312039133d38b28ade5ab8093d (patch) | |
tree | be0846f4746563b92181f0047be84a6cccabd727 /source/blender/blenkernel | |
parent | 8300b5e53987b650c0edd03b892dee1f7da94a0d (diff) |
Layers/Collections: Fix crash when deleting collection
If the collection to be deleted has a nested collection that is directly linked
to a view layer, we were getting a crash.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index f6915cc2432..e2b10de575c 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -188,6 +188,15 @@ bool BKE_collection_remove(ID *owner_id, SceneCollection *sc) return false; } + /* We need to do bottom up removal, otherwise we get a crash when we remove a collection that + * has one of its nested collections linked to a view layer. */ + SceneCollection *scene_collection_nested = sc->scene_collections.first; + while (scene_collection_nested != NULL) { + SceneCollection *scene_collection_next = scene_collection_nested->next; + BKE_collection_remove(owner_id, scene_collection_nested); + scene_collection_nested = scene_collection_next; + } + /* Unlink from the respective collection tree. */ if (!collection_remlink(sc_master, sc)) { BLI_assert(false); |