[Bf-blender-cvs] [b8a36f1b07e] workspaces: Fix crashes on file read

Julian Eisel noreply at git.blender.org
Mon Mar 13 23:23:28 CET 2017


Commit: b8a36f1b07eaba1f109c17912efa2efae94ff922
Author: Julian Eisel
Date:   Mon Mar 13 22:34:14 2017 +0100
Branches: workspaces
https://developer.blender.org/rBb8a36f1b07eaba1f109c17912efa2efae94ff922

Fix crashes on file read

===================================================================

M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/workspace/screen_context.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index c12e87613eb..d943760fe04 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2782,11 +2782,13 @@ static void lib_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook
 static void direct_link_workspace(FileData *fd, WorkSpace *ws)
 {
 	WorkSpaceLayout *act_layout = BKE_workspace_active_layout_get(ws);
+	SceneLayer *layer = BKE_workspace_render_layer_get(ws);
 
 	link_list(fd, BKE_workspace_layouts_get(ws));
 
 	act_layout = newdataadr(fd, act_layout);
 	BKE_workspace_active_layout_set(ws, act_layout);
+	BKE_workspace_render_layer_set(ws, newdataadr(fd, layer));
 }
 
 static void direct_link_workspace_instance_hook(FileData *fd, WorkSpaceInstanceHook *hook)
diff --git a/source/blender/editors/workspace/screen_context.c b/source/blender/editors/workspace/screen_context.c
index 9e49af33bad..0ee61b33102 100644
--- a/source/blender/editors/workspace/screen_context.c
+++ b/source/blender/editors/workspace/screen_context.c
@@ -50,6 +50,7 @@
 #include "BKE_layer.h"
 #include "BKE_screen.h"
 #include "BKE_sequencer.h"
+#include "BKE_workspace.h"
 
 #include "RNA_access.h"
 
@@ -85,7 +86,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
 	bScreen *sc = CTX_wm_screen(C);
 	ScrArea *sa = CTX_wm_area(C);
 	Scene *scene = WM_window_get_active_scene(win);
-	SceneLayer *sl = CTX_data_scene_layer(C);
+	/* can't call BKE_scene_layer_context_active here, it uses G.main->wm which might be NULL on file read. */
+	WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
+	SceneLayer *sl = BKE_workspace_render_layer_get(workspace);
 	Object *obedit = scene->obedit;
 	Object *obact = sl->basact ? sl->basact->object : NULL;




More information about the Bf-blender-cvs mailing list