diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-03 11:28:27 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-03 11:28:39 +0300 |
commit | 5fd3d1fda44fdc5da4b279309004996b1deaa3b4 (patch) | |
tree | f4e7396db416bdbdfe01262afc9846c92191dacb /source/blender/editors/gpencil/gpencil_fill.c | |
parent | 6c8cc91f816d67f2f4ef1d41b226bb8d50a8b0b2 (diff) |
Fix T56217: Segment Fault when using the Fill Brush on Blank GP Object
The error was in any GP object without layers.
Also added a check to avoid paint in a locked layer.
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_fill.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_fill.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 253f0db865e..ec90c826a27 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -987,7 +987,9 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op)) /* set GP datablock */ tgpf->gpd = gpd; tgpf->gpl = BKE_gpencil_layer_getactive(gpd); - + if (tgpf->gpl == NULL) { + tgpf->gpl = BKE_gpencil_layer_addnew(tgpf->gpd, DATA_("GP_Layer"), true); + } tgpf->lock_axis = ts->gp_sculpt.lock_axis; tgpf->oldkey = -1; @@ -1087,6 +1089,12 @@ static void gpencil_fill_cancel(bContext *C, wmOperator *op) static int gpencil_fill_init(bContext *C, wmOperator *op) { tGPDfill *tgpf; + /* cannot paint in locked layer */ + bGPdata *gpd = CTX_data_gpencil_data(C); + bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); + if ((gpl) && (gpl->flag & GP_LAYER_LOCKED)) { + return 0; + } /* check context */ tgpf = op->customdata = gp_session_init_fill(C, op); |