[Bf-blender-cvs] [a9e27f071e4] greasepencil-object: GPencil: Fix errors creating brushes after merge

Antonio Vazquez noreply at git.blender.org
Wed Feb 19 22:26:30 CET 2020


Commit: a9e27f071e412f9bc395b3ddc53c7ee60b5e1117
Author: Antonio Vazquez
Date:   Wed Feb 19 22:21:10 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rBa9e27f071e412f9bc395b3ddc53c7ee60b5e1117

GPencil: Fix errors creating brushes after merge

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

M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenloader/intern/versioning_280.c

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

diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 2b4a96218e9..6772c7dfd45 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -169,8 +169,29 @@ void BKE_brush_init_gpencil_settings(Brush *brush)
 /* add a new gp-brush */
 Brush *BKE_brush_add_gpencil(Main *bmain, ToolSettings *ts, const char *name, eObjectMode mode)
 {
+  Paint *paint = NULL;
   Brush *brush;
-  Paint *paint = &ts->gp_paint->paint;
+  switch (mode) {
+    case OB_MODE_PAINT_GPENCIL: {
+      paint = &ts->gp_paint->paint;
+      break;
+    }
+    case OB_MODE_SCULPT_GPENCIL: {
+      paint = &ts->gp_sculptpaint->paint;
+      break;
+    }
+    case OB_MODE_WEIGHT_GPENCIL: {
+      paint = &ts->gp_weightpaint->paint;
+      break;
+    }
+    case OB_MODE_VERTEX_GPENCIL: {
+      paint = &ts->gp_vertexpaint->paint;
+      break;
+    }
+    default:
+      paint = &ts->gp_paint->paint;
+  }
+
   brush = BKE_brush_add(bmain, name, mode);
 
   BKE_paint_brush_set(paint, brush);
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index f22b6a7f476..136fc368bb3 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1609,11 +1609,12 @@ void do_versions_after_linking_280(Main *bmain, ReportList *UNUSED(reports))
       BKE_paint_ensure_from_paintmode(scene, PAINT_MODE_WEIGHT_GPENCIL);
 
       /* Set default Draw brush. */
-      Paint *paint = &ts->gp_paint->paint;
-      BKE_paint_brush_set(paint, brush);
-      /* Enable cursor by default. */
-      paint->flags |= PAINT_SHOW_BRUSH;
-
+      if (brush != NULL) {
+        Paint *paint = &ts->gp_paint->paint;
+        BKE_paint_brush_set(paint, brush);
+        /* Enable cursor by default. */
+        paint->flags |= PAINT_SHOW_BRUSH;
+      }
       /* Ensure Palette by default. */
       BKE_gpencil_palette_ensure(bmain, scene);
     }



More information about the Bf-blender-cvs mailing list