diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-23 13:19:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-23 13:51:48 +0300 |
commit | d59b74adb38f3ac6b85107aa506e471efbd2a20c (patch) | |
tree | 28e68e70c08a204232cf3b04637e96c6e4a00594 /source/blender/blenloader | |
parent | 858e8f453d48fe8f2285ef2dd1d11cdc099de6d4 (diff) |
Fix T53481: Linked scene crashes on load
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 21 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 8 |
2 files changed, 24 insertions, 5 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 867eb1d749a..6695b6ced37 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2882,7 +2882,15 @@ static void lib_link_workspaces(FileData *fd, Main *bmain) relation = relation->next) { relation->parent = newlibadr(fd, id->lib, relation->parent); - /* relation->value is set in direct_link_workspace_link_scene_data */ + /* relation->value is set in direct_link_workspace_link_scene_data, + * except when loading linked data. */ + Scene *scene = relation->parent; + if (scene->id.lib != NULL) { + relation->value = BLI_findstring(&scene->view_layers, relation->value_idname, offsetof(ViewLayer, name)); + } + if (relation->value == NULL) { + relation->value = scene->view_layers.first; + } } for (WorkSpaceLayout *layout = layouts->first, *layout_next; layout; layout = layout_next) { @@ -6066,12 +6074,15 @@ static void direct_link_workspace_link_scene_data( relation != NULL; relation = relation->next) { - ViewLayer *layer = newdataadr(fd, relation->value); - if (layer) { - BLI_assert(BLI_findindex(&scene->view_layers, layer) != -1); + ViewLayer *view_layer = newdataadr(fd, relation->value); + if (view_layer != NULL) { + BLI_assert(BLI_findindex(&scene->view_layers, view_layer) != -1); /* relation->parent is set in lib_link_workspaces */ - relation->value = layer; } + if (UNLIKELY(view_layer == NULL)) { + view_layer = scene->view_layers.first; + } + relation->value = view_layer; } } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a3cac39f609..a1789ac3d5d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3596,6 +3596,14 @@ static void write_workspace(WriteData *wd, WorkSpace *workspace) { ListBase *layouts = BKE_workspace_layouts_get(workspace); + /* Update the names for file (only need to set on write). */ + for (WorkSpaceDataRelation *relation = workspace->scene_viewlayer_relations.first; + relation; + relation = relation->next) + { + STRNCPY(relation->value_idname, ((ViewLayer *)relation->value)->name); + } + writestruct(wd, ID_WS, WorkSpace, 1, workspace); writelist(wd, DATA, WorkSpaceLayout, layouts); writelist(wd, DATA, WorkSpaceDataRelation, &workspace->hook_layout_relations); |