GPencil: Verify Brush has GPencil data
authorAntonioya <blendergit@gmail.com>
Mon, 6 May 2019 18:34:24 +0000 (20:34 +0200)
committerAntonioya <blendergit@gmail.com>
Mon, 6 May 2019 18:34:24 +0000 (20:34 +0200)
This avoid errors in old files.

source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/gpencil/gpencil_merge.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/gpencil/gpencil_primitive.c
source/blender/editors/gpencil/gpencil_utils.c

index 463c2144276bb120e0f33bba7337706126dc93a4..9ef0657ae8309d8b87ac637f42aae4749c838a23 100644 (file)
@@ -314,7 +314,7 @@ static int gpencil_paintmode_toggle_exec(bContext *C, wmOperator *op)
     BKE_paint_ensure(ts, (Paint **)&ts->gp_paint);
     Paint *paint = &ts->gp_paint->paint;
     /* if not exist, create a new one */
-    if (paint->brush == NULL) {
+    if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
       BKE_brush_gpencil_presets(C);
     }
     BKE_paint_toolslots_brush_validate(bmain, &ts->gp_paint->paint);
index 9d3c2a6e271e636a4c2d4b668b294b06545f852f..93d8555e014ed7862a4ec0c45a79cb2f281910ec 100644 (file)
@@ -110,7 +110,7 @@ static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpo
 
   Paint *paint = &ts->gp_paint->paint;
   /* if not exist, create a new one */
-  if (paint->brush == NULL) {
+  if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
     /* create new brushes */
     BKE_brush_gpencil_presets(C);
   }
index b1b29356060e558cd45236f0ee9417240d5f3bae..cd1ebc91fbb2f53fe919dcadfe0f73b2b558e179 100644 (file)
@@ -1819,7 +1819,7 @@ static void gp_init_drawing_brush(bContext *C, tGPsdata *p)
   Paint *paint = &ts->gp_paint->paint;
   bool changed = false;
   /* if not exist, create a new one */
-  if (paint->brush == NULL) {
+  if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
     /* create new brushes */
     BKE_brush_gpencil_presets(C);
     changed = true;
index 08fee2bb3935f51f383871bf81351a4bc4e92323..bff17bf5078a0299376d9dbd9c5115cbc450dc19 100644 (file)
@@ -314,7 +314,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
   /* if brush doesn't exist, create a new one */
   Paint *paint = &ts->gp_paint->paint;
   /* if not exist, create a new one */
-  if (paint->brush == NULL) {
+  if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
     /* create new brushes */
     BKE_brush_gpencil_presets(C);
   }
index 129bd01574ca20658ff30025d973e8f65eccb7a8..93a80f0fcf800a19b54376e6573be62358a24b23 100644 (file)
@@ -1387,7 +1387,7 @@ void ED_gpencil_add_defaults(bContext *C, Object *ob)
   BKE_paint_ensure(ts, (Paint **)&ts->gp_paint);
   Paint *paint = &ts->gp_paint->paint;
   /* if not exist, create a new one */
-  if (paint->brush == NULL) {
+  if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
     /* create new brushes */
     BKE_brush_gpencil_presets(C);
   }