From a8f2fea5e2670007b97d0293aea4108b02415b4d Mon Sep 17 00:00:00 2001 From: raistlin7447 Date: Thu, 2 Jul 2026 22:29:28 -0500 Subject: [PATCH] fix: crash in Measure tool when a plain edge is the first selection (#14538) * fix: crash in Measure tool when a plain edge is the first selection The SPHERE_2 gripper raycaster called get_feature_offset() on .first.feature instead of .second.feature (copy-pasted from the SPHERE_1 block). Plain planar-border edges store no extra point, so the Edge branch dereferenced an empty optional behind a release-stripped assert, aborting on Flatpak and undefined behavior elsewhere. Point the SPHERE_2 raycaster at .second.feature and fall the Edge branch back to the edge midpoint. Fixes #14018 --- src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 6c6f913276..0bdc3d1302 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -91,9 +91,14 @@ Vec3d GLGizmoMeasure::get_feature_offset(const Measure::SurfaceFeature &feature) } case Measure::SurfaceFeatureType::Edge: { - std::optional p = feature.get_extra_point(); - assert(p.has_value()); - ret = *p; + // Only polygon edges store an extra point (the polygon centre); plain edges have none. + const std::optional extra = feature.get_extra_point(); + if (extra.has_value()) + ret = *extra; + else { + const auto [pt1, pt2] = feature.get_edge(); + ret = 0.5 * (pt1 + pt2); + } break; } case Measure::SurfaceFeatureType::Point: @@ -1065,7 +1070,7 @@ void GLGizmoMeasure::on_render() if (requires_raycaster_update) { if (m_gripper_id_raycast_map.find(GripperType::SPHERE_2) != m_gripper_id_raycast_map.end()) { - m_gripper_id_raycast_map[GripperType::SPHERE_2]->set_transform(Geometry::translation_transform(get_feature_offset(*m_selected_features.first.feature)) * + m_gripper_id_raycast_map[GripperType::SPHERE_2]->set_transform(Geometry::translation_transform(get_feature_offset(*m_selected_features.second.feature)) * Geometry::scale_transform(inv_zoom)); } }