Fix T83510: Convert Gpencil to curve crash when stroke has zero points

If the stroke had zero points the pointer returned NULL.

Also replaced for loop by FOREACH macro.

This is a corner case of "empty" strokes without points.
This commit is contained in:
Antonio Vazquez 2020-12-07 19:08:29 +01:00
parent 3e005a3214
commit 29fb12da58
Notes: blender-bot 2023-02-13 22:37:44 +01:00
Referenced by issue #83510, Convert Gpencil to curve crash when stroke has zero points
1 changed files with 5 additions and 2 deletions

View File

@ -1312,7 +1312,7 @@ static void gpencil_layer_to_curve(bContext *C,
Scene *scene = CTX_data_scene(C);
bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, CFRA, GP_GETFRAME_USE_PREV);
bGPDstroke *gps, *prev_gps = NULL;
bGPDstroke *prev_gps = NULL;
Object *ob;
Curve *cu;
Nurb *nu = NULL;
@ -1353,7 +1353,10 @@ static void gpencil_layer_to_curve(bContext *C,
gtd->inittime = ((bGPDstroke *)gpf->strokes.first)->inittime;
/* add points to curve */
for (gps = gpf->strokes.first; gps; gps = gps->next) {
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
if (gps->totpoints < 1) {
continue;
}
const bool add_start_point = (link_strokes && !(prev_gps));
const bool add_end_point = (link_strokes && !(gps->next));