From 4f9e946dfb7567fbb606f0dfa2a625b856a5514b Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Sat, 30 Nov 2024 21:38:59 +0800 Subject: [PATCH] Fix bug ShortestPath.cpp (#13331) (#7615) Accessing a moved object. Also this method create an unused "out" variable by removing from the parameter. I guess It should update the parameter object? Anyway, seems very wrong (cherry picked from commit 534792e249da3efb83a62279f532b6690d028592) Co-authored-by: Merill --- src/libslic3r/ShortestPath.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/ShortestPath.cpp b/src/libslic3r/ShortestPath.cpp index a2a2680f5..3aa99e2b7 100644 --- a/src/libslic3r/ShortestPath.cpp +++ b/src/libslic3r/ShortestPath.cpp @@ -1910,14 +1910,15 @@ static inline void improve_ordering_by_two_exchanges_with_segment_flipping(Polyl for (const FlipEdge &edge : edges) { Polyline &pl = polylines[edge.source_index]; out.emplace_back(std::move(pl)); - if (edge.p2 == pl.first_point().cast()) { + if (edge.p2 == out.back().first_point().cast()) { // Polyline is flipped. out.back().reverse(); } else { // Polyline is not flipped. - assert(edge.p1 == pl.first_point().cast()); + assert(edge.p1 == out.back().first_point().cast()); } } + polylines = out; #ifndef NDEBUG double cost_final = cost();