From 47ff54b0080b5015244cd64a4f69f3baca2c5ab0 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Thu, 25 Jun 2020 17:13:21 +0200 Subject: [PATCH] GPencil: Ensure previous brush is set when change mode In some situations, the previous brush is not set. This usually happens with previous version files. Related to T78155. --- source/blender/blenkernel/intern/brush.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 0a991d3ef4a..417fd182e73 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1185,6 +1185,11 @@ void BKE_brush_gpencil_paint_presets(Main *bmain, ToolSettings *ts, const bool r if (reset || brush_prev == NULL) { BKE_paint_brush_set(paint, deft_draw); } + else { + if (brush_prev != NULL) { + BKE_paint_brush_set(paint, brush_prev); + } + } } /* Create a set of grease pencil Vertex Paint presets. */ @@ -1227,6 +1232,11 @@ void BKE_brush_gpencil_vertex_presets(Main *bmain, ToolSettings *ts, const bool if (reset || brush_prev == NULL) { BKE_paint_brush_set(vertexpaint, deft_vertex); } + else { + if (brush_prev != NULL) { + BKE_paint_brush_set(vertexpaint, brush_prev); + } + } } /* Create a set of grease pencil Sculpt Paint presets. */ @@ -1297,6 +1307,11 @@ void BKE_brush_gpencil_sculpt_presets(Main *bmain, ToolSettings *ts, const bool if (reset || brush_prev == NULL) { BKE_paint_brush_set(sculptpaint, deft_sculpt); } + else { + if (brush_prev != NULL) { + BKE_paint_brush_set(sculptpaint, brush_prev); + } + } } /* Create a set of grease pencil Weight Paint presets. */ @@ -1318,6 +1333,11 @@ void BKE_brush_gpencil_weight_presets(Main *bmain, ToolSettings *ts, const bool if (reset || brush_prev == NULL) { BKE_paint_brush_set(weightpaint, deft_weight); } + else { + if (brush_prev != NULL) { + BKE_paint_brush_set(weightpaint, brush_prev); + } + } } struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode)