Fix: Grease Pencil sculpting crashes when sculpting on layers without any strokes

Reported by @loochmunz. I've also gone through checking for and fixing other places
where this was also occurring.


To be included in 2.78
This commit is contained in:
Joshua Leung 2016-09-21 17:02:17 +12:00
parent 0b9cfbf6a8
commit 586c58902d
Notes: blender-bot 2023-02-14 09:34:18 +01:00
Referenced by issue #49421, Crach with GP when sculpting empty layer.
2 changed files with 12 additions and 4 deletions

View File

@ -1350,6 +1350,10 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
bGPDframe *gpf = gpl->actframe;
if (gpf == NULL)
continue;
/* calculate difference matrix if parent object */
if (gpl->parent != NULL) {
ED_gpencil_parent_location(gpl, diff_mat);
@ -1358,10 +1362,8 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
else {
parented = false;
}
bGPDframe *gpf = gpl->actframe;
bGPDstroke *gps;
for (gps = gpf->strokes.first; gps; gps = gps->next) {
for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
/* skip strokes that are invalid for current view */
if (ED_gpencil_stroke_can_use(C, gps) == false)
continue;

View File

@ -1504,6 +1504,9 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op)
/* loop all selected strokes */
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
if (gpl->actframe == NULL)
continue;
for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) {
bGPDpalettecolor *palcolor = gps->palcolor;
@ -1724,6 +1727,9 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers)
{
bGPDframe *gpf = gpl->actframe;
if (gpf == NULL)
continue;
for (gps = gpf->strokes.first; gps; gps = gpsn) {
gpsn = gps->next;
if (gps->flag & GP_STROKE_SELECT) {