Fix T96352: Gpencil crash using Normalize Thickness with Curves

The stroke curve data could be NULL.
This commit is contained in:
Antonio Vazquez 2022-03-12 10:33:32 +01:00
parent 39c070ed8f
commit 8617ab153e
Notes: blender-bot 2023-02-14 08:58:01 +01:00
Referenced by issue #96352, Grease Pencil > Stroke > Normalize Thickness Causes Crash
Referenced by issue #96241, 3.1: Potential candidates for corrective releases
1 changed files with 5 additions and 4 deletions

View File

@ -5430,9 +5430,10 @@ static int gpencil_stroke_normalize_exec(bContext *C, wmOperator *op)
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
}
bool selected = (is_curve_edit) ? gps->editcurve->flag |= GP_CURVE_SELECT :
(gps->flag & GP_STROKE_SELECT);
bool is_curve_ready = (gps->editcurve != NULL);
bool selected = (is_curve_edit && is_curve_ready) ?
gps->editcurve->flag |= GP_CURVE_SELECT :
(gps->flag & GP_STROKE_SELECT);
if (!selected) {
continue;
}
@ -5445,7 +5446,7 @@ static int gpencil_stroke_normalize_exec(bContext *C, wmOperator *op)
}
/* Loop all Polyline points. */
if (!is_curve_edit) {
if (!is_curve_edit || !is_curve_ready) {
for (int i = 0; i < gps->totpoints; i++) {
bGPDspoint *pt = &gps->points[i];
if (mode == GP_NORMALIZE_THICKNESS) {