From ab0e839f9a96841615f747a4481323b280baf7c4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 May 2019 13:58:02 +1000 Subject: Fix T65074: Crash on switching color Make buttons to take active `Paint` from the context. D4946 by @Gvgeo --- source/blender/editors/interface/interface_handlers.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index b9c77b13401..b8e97f58c2f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5563,9 +5563,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co if ((int)(but->a1) == UI_PALETTE_COLOR) { if (!event->ctrl) { float color[3]; - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Paint *paint = BKE_paint_get_active(scene, view_layer); + Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); if (brush->flag & BRUSH_USE_GRADIENT) { @@ -5580,6 +5578,8 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co } } else { + Scene *scene = CTX_data_scene(C); + if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color); BKE_brush_color_set(scene, brush, color); -- cgit v1.2.3