[Bf-blender-cvs] [36b9ee12775] blender2.8: Fix T57390: properties editor crash creating new scene in some cases.

Brecht Van Lommel noreply at git.blender.org
Wed Nov 7 14:57:55 CET 2018


Commit: 36b9ee1277519f1ae471afbc0a99e26eee1acbe4
Author: Brecht Van Lommel
Date:   Wed Nov 7 14:51:06 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB36b9ee1277519f1ae471afbc0a99e26eee1acbe4

Fix T57390: properties editor crash creating new scene in some cases.

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

M	source/blender/editors/space_buttons/buttons_context.c

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

diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index e63dd799582..226a663971e 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -412,7 +412,8 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
 		scene = path->ptr[path->len - 1].data;
 
 		if (scene) {
-			ViewLayer *view_layer = CTX_data_view_layer(C);
+			wmWindow *window = CTX_wm_window(C);
+			ViewLayer *view_layer = WM_window_get_active_view_layer(window);
 			br = BKE_paint_brush(BKE_paint_get_active(scene, view_layer));
 		}
 
@@ -467,7 +468,8 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path
 #ifdef WITH_FREESTYLE
 static bool buttons_context_linestyle_pinnable(const bContext *C, ViewLayer *view_layer)
 {
-	Scene *scene = CTX_data_scene(C);
+	wmWindow *window = CTX_wm_window(C);
+	Scene *scene = WM_window_get_active_scene(window);
 	FreestyleConfig *config;
 	SpaceButs *sbuts;
 
@@ -491,13 +493,15 @@ static bool buttons_context_linestyle_pinnable(const bContext *C, ViewLayer *vie
 
 static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag)
 {
+	/* Note we don't use CTX_data here, instead we get it from the window.
+	 * Otherwise there is a loop reading the context that we are setting. */
 	SpaceButs *sbuts = CTX_wm_space_buts(C);
-	Scene *scene = CTX_data_scene(C);
-	ViewLayer *view_layer = CTX_data_view_layer(C);
 	wmWindow *window = CTX_wm_window(C);
+	Scene *scene = WM_window_get_active_scene(window);
+	ViewLayer *view_layer = WM_window_get_active_view_layer(window);
+	Object *ob = OBACT(view_layer);
 	ID *id;
 	int found;
-	Object *ob = CTX_data_active_object(C);
 
 	memset(path, 0, sizeof(*path));
 	path->flag = flag;
@@ -593,7 +597,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
 
 static int buttons_shading_context(const bContext *C, int mainb)
 {
-	Object *ob = CTX_data_active_object(C);
+	wmWindow *window = CTX_wm_window(C);
+	ViewLayer *view_layer = WM_window_get_active_view_layer(window);
+	Object *ob = OBACT(view_layer);
 
 	if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE))
 		return 1;
@@ -605,7 +611,9 @@ static int buttons_shading_context(const bContext *C, int mainb)
 
 static int buttons_shading_new_context(const bContext *C, int flag)
 {
-	Object *ob = CTX_data_active_object(C);
+	wmWindow *window = CTX_wm_window(C);
+	ViewLayer *view_layer = WM_window_get_active_view_layer(window);
+	Object *ob = OBACT(view_layer);
 
 	if (flag & (1 << BCONTEXT_MATERIAL))
 		return BCONTEXT_MATERIAL;



More information about the Bf-blender-cvs mailing list