diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-06-05 10:57:21 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2019-06-05 10:57:21 +0300 |
commit | d46aee298210282a9cdd8ddca7f5941cfa03e2f6 (patch) | |
tree | 308951cd1058b6a56f2639afe2f4a5004411c785 /source/blender/editors/gpencil/gpencil_primitive.c | |
parent | e80cbdac331a3f9b67217ed9fcb5235c447d0c0f (diff) |
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
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_primitive.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 18 |
1 files changed, 8 insertions, 10 deletions
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"); |