Fix crash when reordering layers (#1492)

This commit is contained in:
0HyperCube
2023-12-09 13:08:46 +00:00
committed by GitHub
parent c33ba1b315
commit 10863acd83
3 changed files with 10 additions and 0 deletions
@@ -525,6 +525,10 @@ impl<'a> ModifyInputsContext<'a> {
let mut delete_nodes = vec![id];
for (_node, id) in self.network.upstream_flow_back_from_nodes(vec![id], true) {
// Don't delete the node if other layers depend on it.
if self.outwards_links.get(&id).is_some_and(|nodes| nodes.len() > 1) {
break;
}
if self.outwards_links.get(&id).is_some_and(|outwards| outwards.len() == 1) {
delete_nodes.push(id);
}
@@ -33,6 +33,7 @@ impl OriginalTransforms {
pub fn update<'a>(&mut self, selected: &'a [LayerNodeIdentifier], document: &'a Document, shape_editor: Option<&'a ShapeState>) {
match self {
OriginalTransforms::Layer(layer_map) => {
layer_map.retain(|layer, _| selected.contains(layer));
for &layer in selected {
layer_map.entry(layer).or_insert_with(|| document.metadata.upstream_transform(layer.to_node()));
}