From cf8a317f24b201817498f8f9021ab8383e07e656 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 15 Feb 2024 16:47:41 +0000 Subject: [PATCH] layout: remove inserted segbend if updating bows fails --- src/layout/layout.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/layout/layout.rs b/src/layout/layout.rs index 426a9ca..0af46b8 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -277,13 +277,17 @@ impl Layout { } if let Some(outer) = self.primitive(segbend.bend).outer() { - self.update_this_and_outward_bows(outer); + self.update_this_and_outward_bows(outer).map_err(|err| { + let joint = self.primitive(segbend.bend).other_joint(segbend.dot); + self.remove_segbend(&segbend, joint.into()); + err + })?; } // Segs must not cross. if let Some(collision) = self.detect_collision(segbend.seg.into()) { - let end = self.primitive(segbend.bend).other_joint(segbend.dot); - self.remove_segbend(&segbend, end.into()); + let joint = self.primitive(segbend.bend).other_joint(segbend.dot); + self.remove_segbend(&segbend, joint.into()); return Err(collision.into()); }