From 2f4dac223cfbcf2f091b30b9a5b212ed5842b507 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 17 Jul 2025 12:39:19 +0200 Subject: [PATCH] fix(geometry/with_rtree): Do not remove only-modified dots when applying edit This fixes a panic when undoing some bands. 180952c94f1c7c56c2ce5d2bdd3ab672aa0ccfec did not fix this problem because we did not stop removing modified dots. --- src/geometry/with_rtree.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/geometry/with_rtree.rs b/src/geometry/with_rtree.rs index a85a3ba..19a93c6 100644 --- a/src/geometry/with_rtree.rs +++ b/src/geometry/with_rtree.rs @@ -563,7 +563,12 @@ impl< for (dot, (maybe_old_data, maybe_new_data)) in &edit.dots { if let (Some(_), Some(weight)) = (maybe_old_data, maybe_new_data) { self.modify_dot(*dot, |geometry, dot| { - geometry.remove_primitive(dot.into()); + // Note that we do not remove the dot. This is because doing + // so removes its edges, which we would have to restore + // afterwards. So it's easier to only update the weight. + + // Despite this method's name, it actually does not add the + // dot, it updates it. geometry .add_dot_at_index(GenericIndex::::new(dot.petgraph_index()), *weight); })