diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-10 15:11:12 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-10 17:30:17 +0300 |
commit | e6dccb4b01f9c62d101dbb52d3e7f7cb7d138afa (patch) | |
tree | bbfeef471de8914e34e61791cbe612b7ab335e23 | |
parent | dd7a727910dd02d830d11d726acf52fd88ea6e8e (diff) |
Fix T55826, fix T55804: crash after copying scene with linked objects.
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 80329a1d328..2f5c8e7817e 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -346,7 +346,9 @@ void BKE_view_layer_base_select(struct ViewLayer *view_layer, Base *selbase) /**************************** Copy View Layer and Layer Collections ***********************/ -static void layer_collections_copy_data(ListBase *layer_collections_dst, const ListBase *layer_collections_src) +static void layer_collections_copy_data( + ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, + ListBase *layer_collections_dst, const ListBase *layer_collections_src) { BLI_duplicatelist(layer_collections_dst, layer_collections_src); @@ -355,9 +357,15 @@ static void layer_collections_copy_data(ListBase *layer_collections_dst, const L while (layer_collection_dst != NULL) { layer_collections_copy_data( + view_layer_dst, + view_layer_src, &layer_collection_dst->layer_collections, &layer_collection_src->layer_collections); + if (layer_collection_src == view_layer_src->active_collection) { + view_layer_dst->active_collection = layer_collection_dst; + } + layer_collection_dst = layer_collection_dst->next; layer_collection_src = layer_collection_src->next; } @@ -369,7 +377,7 @@ static void layer_collections_copy_data(ListBase *layer_collections_dst, const L * \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more). */ void BKE_view_layer_copy_data( - Scene *UNUSED(scene_dst), const Scene *UNUSED(scene_src), + Scene *scene_dst, const Scene *UNUSED(scene_src), ViewLayer *view_layer_dst, const ViewLayer *view_layer_src, const int flag) { @@ -396,9 +404,15 @@ void BKE_view_layer_copy_data( } } - layer_collections_copy_data(&view_layer_dst->layer_collections, &view_layer_src->layer_collections); + view_layer_dst->active_collection = NULL; + layer_collections_copy_data( + view_layer_dst, + view_layer_src, + &view_layer_dst->layer_collections, + &view_layer_src->layer_collections); - // TODO: not always safe to free BKE_layer_collection_sync(scene_dst, view_layer_dst); + LayerCollection *lc_scene_dst = view_layer_dst->layer_collections.first; + lc_scene_dst->collection = scene_dst->master_collection; } void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, const char *newname) @@ -598,6 +612,10 @@ static int layer_collection_sync( BLI_findptr(lb_scene, lc->collection, offsetof(CollectionChild, collection)) : NULL; if (!collection) { + if (lc == view_layer->active_collection) { + view_layer->active_collection = NULL; + } + /* Free recursively. */ layer_collection_free(view_layer, lc); BLI_freelinkN(lb_layer, lc); |