diff --git a/editor/src/messages/portfolio/document/node_graph/graph_operation_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/graph_operation_message_handler.rs index 2954a6d4..1a682387 100644 --- a/editor/src/messages/portfolio/document/node_graph/graph_operation_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/graph_operation_message_handler.rs @@ -424,6 +424,7 @@ impl<'a> ModifyInputsContext<'a> { let [mut old_bounds_min, mut old_bounds_max] = [DVec2::ZERO, DVec2::ONE]; let [mut new_bounds_min, mut new_bounds_max] = [DVec2::ZERO, DVec2::ONE]; + let mut empty = false; self.modify_inputs("Shape", false, |inputs, _node_id, _metadata| { let [subpaths, mirror_angle_groups] = inputs.as_mut_slice() else { @@ -448,11 +449,17 @@ impl<'a> ModifyInputsContext<'a> { [old_bounds_min, old_bounds_max] = transform_utils::nonzero_subpath_bounds(subpaths); transform_utils::VectorModificationState { subpaths, mirror_angle_groups }.modify(modification); + empty = !subpaths.iter().any(|subpath| !subpath.is_empty()); [new_bounds_min, new_bounds_max] = transform_utils::nonzero_subpath_bounds(subpaths); }); self.update_bounds([old_bounds_min, old_bounds_max], [new_bounds_min, new_bounds_max]); + if empty { + if let Some(layer) = self.layer_node { + self.responses.add(DocumentMessage::DeleteLayer { layer_path: vec![layer] }) + } + } } fn brush_modify(&mut self, strokes: Vec) { diff --git a/libraries/bezier-rs/src/subpath/core.rs b/libraries/bezier-rs/src/subpath/core.rs index 6798bf8b..ea0c210b 100644 --- a/libraries/bezier-rs/src/subpath/core.rs +++ b/libraries/bezier-rs/src/subpath/core.rs @@ -141,6 +141,9 @@ impl Subpath { /// Write the curve argument to the string (the d="..." part) pub fn subpath_to_svg(&self, svg: &mut String, transform: glam::DAffine2) -> std::fmt::Result { + if self.is_empty() { + return Ok(()); + } let start = transform.transform_point2(self[0].anchor); write!(svg, "{SVG_ARG_MOVE}{},{}", start.x, start.y)?; for bezier in self.iter() { diff --git a/libraries/bezier-rs/src/subpath/mod.rs b/libraries/bezier-rs/src/subpath/mod.rs index 6cba7732..c720d468 100644 --- a/libraries/bezier-rs/src/subpath/mod.rs +++ b/libraries/bezier-rs/src/subpath/mod.rs @@ -51,6 +51,9 @@ impl Iterator for SubpathIter<'_, Manipul // Returns the Bezier representation of each `Subpath` segment, defined between a pair of adjacent manipulator points. fn next(&mut self) -> Option { + if self.subpath.is_empty() { + return None; + } let len = self.subpath.len() - 1 + match self.subpath.closed { true => 1,