Fix: Grease Pencil: Join operator connects wrong ends and crashes

Sometimes when joining two or more strokes ends that were not close would be merge.

This was caused by using `dst_drawing` instead of `tmp_drawing`. The function
`compute_closest_range_to` would try to the the first and last point by using the drawing
that the `PointsRange` would have a pointer to.
But the `working_range` would point to `dst_drawing` with would have the `CurveGeometry`
of `dst_curves` instead of `tmp_curves`
This would lead to the wrong first and last points being used for deciding which end
to connect.

This problem could also lead to a crash by trying to get a curve that does not exist.

Pull Request: https://projects.blender.org/blender/blender/pulls/144668
This commit is contained in:
Casey Bianco-Davis
2025-08-27 13:39:36 +02:00
committed by Falk David
parent b33e372d02
commit 11afddc681

View File

@@ -507,10 +507,12 @@ wmOperatorStatus grease_pencil_join_selection_exec(bContext *C, wmOperator *op)
/* Temporary geometry where to perform the logic
* Once it gets stable, it is appended all at once to the destination curves */
bke::CurvesGeometry tmp_curves(selected_points_count, 1);
Drawing tmp_drawing;
tmp_drawing.strokes_for_write() = bke::CurvesGeometry(selected_points_count, 1);
bke::CurvesGeometry &tmp_curves = tmp_drawing.strokes_for_write();
const PointsRange working_range = copy_point_attributes(
ranges_selected, tmp_curves, *dst_drawing);
ranges_selected, tmp_curves, tmp_drawing);
copy_curve_attributes(ranges_selected, tmp_curves, *dst_drawing);
clear_selection_attribute(ranges_selected);