From 11afddc681d05658e6d141015cc276ca3e1e7c59 Mon Sep 17 00:00:00 2001 From: Casey Bianco-Davis Date: Wed, 27 Aug 2025 13:39:36 +0200 Subject: [PATCH] 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 --- .../grease_pencil/intern/grease_pencil_join_selection.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_join_selection.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_join_selection.cc index a3db28b7603..67e74788657 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_join_selection.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_join_selection.cc @@ -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);