From 36b9ee1277519f1ae471afbc0a99e26eee1acbe4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 Nov 2018 14:51:06 +0100 Subject: Fix T57390: properties editor crash creating new scene in some cases. --- .../editors/space_buttons/buttons_context.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/space_buttons') 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; -- cgit v1.2.3