Fix T65074: Crash on switching color

Make buttons to take active `Paint` from the context.

D4946 by @Gvgeo
This commit is contained in:
2019-05-27 13:58:02 +10:00
parent d525c76003
commit ab0e839f9a

View File

@@ -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);