Fix deleting all artboards without crashing (#1502)
* Fix delete all artboards * Remove unused import causing warning --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
parent
bfee09fe75
commit
421e7c025f
|
|
@ -713,9 +713,11 @@ impl MessageHandler<GraphOperationMessage, (&mut Document, &mut NodeGraphMessage
|
|||
}
|
||||
GraphOperationMessage::ClearArtboards => {
|
||||
let mut modify_inputs = ModifyInputsContext::new(document, node_graph, responses);
|
||||
let artboard_nodes = modify_inputs.network.nodes.iter().filter(|(_, node)| node.name == "Artboard").map(|(id, _)| *id).collect::<Vec<_>>();
|
||||
for id in artboard_nodes {
|
||||
modify_inputs.delete_layer(id);
|
||||
let layer_nodes = modify_inputs.network.nodes.iter().filter(|(_, node)| node.is_layer()).map(|(id, _)| *id).collect::<Vec<_>>();
|
||||
for layer in layer_nodes {
|
||||
if modify_inputs.network.upstream_flow_back_from_nodes(vec![layer], true).any(|(node, _id)| node.name == "Artboard") {
|
||||
modify_inputs.delete_layer(layer);
|
||||
}
|
||||
}
|
||||
document.load_network_structure();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ impl LayoutHolder for MenuBarMessageHandler {
|
|||
no_active_document,
|
||||
MenuBarEntryChildren(vec![vec![MenuBarEntry {
|
||||
label: "Clear Artboards".into(),
|
||||
action: MenuBarEntry::create_action(|_| DialogMessage::RequestComingSoonDialog { issue: None }.into()),
|
||||
action: MenuBarEntry::create_action(|_| GraphOperationMessage::ClearArtboards.into()),
|
||||
disabled: no_active_document,
|
||||
..MenuBarEntry::default()
|
||||
}]]),
|
||||
|
|
|
|||
Loading…
Reference in New Issue