Fix bug ShortestPath.cpp (#13331)

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
This commit is contained in:
Merill 2024-09-03 16:14:05 +02:00 committed by Lukas Matena
parent ae0824a10d
commit 534792e249

View File

@ -1957,14 +1957,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<double>()) {
if (edge.p2 == out.back().first_point().cast<double>()) {
// Polyline is flipped.
out.back().reverse();
} else {
// Polyline is not flipped.
assert(edge.p1 == pl.first_point().cast<double>());
assert(edge.p1 == out.back().first_point().cast<double>());
}
}
polylines = out;
#ifndef NDEBUG
double cost_final = cost();