Fix crash deleting mask vertices

The active vertex was only cleared when it was part of the active-spline
(which isn't guaranteed).

Duplicating & deleting left the active vertex pointing to freed memory.
This commit is contained in:
Campbell Barton
2024-10-04 11:46:34 +10:00
parent 44bb032590
commit 18da036ecc

View File

@@ -1431,15 +1431,21 @@ static int delete_exec(bContext *C, wmOperator * /*op*/)
}
if (count == 0) {
/* Update active. */
if (mask_layer->act_point) {
if (ARRAY_HAS_ITEM(mask_layer->act_point, spline->points, spline->tot_point)) {
mask_layer->act_point = nullptr;
}
}
if (spline == mask_layer->act_spline) {
mask_layer->act_spline = nullptr;
}
/* delete the whole spline */
BLI_remlink(&mask_layer->splines, spline);
BKE_mask_spline_free(spline);
if (spline == mask_layer->act_spline) {
mask_layer->act_spline = nullptr;
mask_layer->act_point = nullptr;
}
BKE_mask_layer_shape_changed_remove(mask_layer, mask_layer_shape_ofs, tot_point_orig);
}
else {