diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2017-12-01 20:06:06 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-12-01 20:14:24 +0300 |
commit | 108c4bd5026d2843c8bd49ffb1cee41d6d905375 (patch) | |
tree | 6877b08feedb66ede84a56f7b95fd177f4cc195d /source/blender | |
parent | d10578df46ee82889e5bb4ff044dd3a57e453e9a (diff) |
Fix crash reading 2.8 files with workspace.view_layer set
Stupid error from e8c15e0ed15f8369d.
Also removed WorkSpace.view_layer usage and marked as deprecated.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/workspace.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 8 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 16 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_workspace_types.h | 2 |
4 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/workspace.c b/source/blender/blenkernel/intern/workspace.c index b6b7d936c76..8554cf0fb28 100644 --- a/source/blender/blenkernel/intern/workspace.c +++ b/source/blender/blenkernel/intern/workspace.c @@ -445,7 +445,6 @@ ViewLayer *BKE_workspace_view_layer_get(const WorkSpace *workspace, const Scene } void BKE_workspace_view_layer_set(WorkSpace *workspace, ViewLayer *layer, Scene *scene) { - workspace->view_layer = layer; workspace_relation_ensure_updated(&workspace->scene_viewlayer_relations, scene, layer); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a91c83c68ef..e6d2be02977 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6188,6 +6188,14 @@ static void direct_link_workspace_link_scene_data( relation->value = layer; } } + + if (workspace->view_layer) { /* this was temporariliy used during 2.8 project. Keep files compatible */ + ViewLayer *layer = newdataadr(fd, workspace->view_layer); + /* only set when layer is from the scene we read */ + if (layer && (BLI_findindex(&scene->view_layers, layer) != -1)) { + workspace->view_layer = layer; + } + } } } diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 8f2295781bf..c718702388a 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -549,6 +549,22 @@ void do_versions_after_linking_280(Main *main) } } + if (!MAIN_VERSION_ATLEAST(main, 280, 3)) { + for (WorkSpace *workspace = main->workspaces.first; workspace; workspace = workspace->id.next) { + if (workspace->view_layer) { + /* During 2.8 work we temporarly stored view-layer in the + * workspace directly, but should be stored there per-scene. */ + for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { + if (BLI_findindex(&scene->view_layers, workspace->view_layer) > -1) { + BKE_workspace_view_layer_set(workspace, workspace->view_layer, scene); + workspace->view_layer = NULL; + } + } + } + BLI_assert(workspace->view_layer == NULL); + } + } + { /* Since we don't have access to FileData we check the (always valid) master collection of the group. */ for (Group *group = main->group.first; group; group = group->id.next) { diff --git a/source/blender/makesdna/DNA_workspace_types.h b/source/blender/makesdna/DNA_workspace_types.h index 11a67692b8b..adc3c1fef2b 100644 --- a/source/blender/makesdna/DNA_workspace_types.h +++ b/source/blender/makesdna/DNA_workspace_types.h @@ -95,7 +95,7 @@ typedef struct WorkSpace { /* should be: '#ifdef USE_WORKSPACE_TOOL'. */ bToolDef tool; - struct ViewLayer *view_layer DNA_PRIVATE_WORKSPACE; + struct ViewLayer *view_layer DNA_DEPRECATED; struct ViewRender view_render; } WorkSpace; |