[Bf-blender-cvs] [d46aee29821] master: GPencil: Create new set of brushes for Win32 damaged files when use primitives

Antonio Vazquez noreply at git.blender.org
Wed Jun 5 09:57:53 CEST 2019


Commit: d46aee298210282a9cdd8ddca7f5941cfa03e2f6
Author: Antonio Vazquez
Date:   Wed Jun 5 09:57:21 2019 +0200
Branches: master
https://developer.blender.org/rBd46aee298210282a9cdd8ddca7f5941cfa03e2f6

GPencil: Create new set of brushes for Win32 damaged files when use primitives

Some old Win32 files could have the brushes damaged and this produces a segment fault. Now, if the brush is damaged, a new set of brushes is created.

Related to T61413

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

M	source/blender/editors/gpencil/gpencil_primitive.c

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

diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index bff17bf5078..d6497e6e58e 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -305,21 +305,11 @@ static void gpencil_primitive_allocate_memory(tGPDprimitive *tgpi)
 /* Helper: Create internal strokes primitives data */
 static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
 {
-  ToolSettings *ts = CTX_data_tool_settings(C);
   Depsgraph *depsgraph = CTX_data_depsgraph(C);
   int cfra_eval = (int)DEG_get_ctime(depsgraph);
 
   bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
 
-  /* 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) || (paint->brush->gpencil_settings == NULL)) {
-    /* create new brushes */
-    BKE_brush_gpencil_presets(C);
-  }
-  tgpi->brush = paint->brush;
-
   /* if layer doesn't exist, create a new one */
   if (gpl == NULL) {
     gpl = BKE_gpencil_layer_addnew(tgpi->gpd, DATA_("Primitives"), true);
@@ -1106,6 +1096,8 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
   Main *bmain = CTX_data_main(C);
   Scene *scene = CTX_data_scene(C);
   Depsgraph *depsgraph = CTX_data_depsgraph(C);
+  Paint *paint = &ts->gp_paint->paint;
+
   int cfra_eval = (int)DEG_get_ctime(depsgraph);
 
   /* create temporary operator data */
@@ -1136,6 +1128,12 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
   /* region where paint was originated */
   tgpi->gpd->runtime.ar = tgpi->ar;
 
+  /* if brush doesn't exist, create a new set (fix damaged files from old versions) */
+  if ((paint->brush == NULL) || (paint->brush->gpencil_settings == NULL)) {
+    BKE_brush_gpencil_presets(C);
+  }
+  tgpi->brush = paint->brush;
+
   /* control points */
   tgpi->gpd->runtime.cp_points = MEM_callocN(sizeof(bGPDcontrolpoint) * MAX_CP,
                                              "gp primitive cpoint");



More information about the Bf-blender-cvs mailing list