Fix crash from empty document with no artboards introduced in #2028 (#2036)

* Fix me crashing the editor due to not paying attention

* Swap two lines for consistency

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
James Lindsay 2024-10-14 19:24:51 +01:00 committed by GitHub
parent a761e7803e
commit b028bbb8cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 4 deletions

View File

@ -2140,10 +2140,18 @@ fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'
impl<'a> ClickXRayIter<'a> {
fn new(network_interface: &'a NodeNetworkInterface, target: XRayTarget) -> Self {
Self {
next_layer: LayerNodeIdentifier::ROOT_PARENT.first_child(network_interface.document_metadata()),
network_interface,
parent_targets: vec![(LayerNodeIdentifier::ROOT_PARENT, target)],
if let Some(first_layer) = LayerNodeIdentifier::ROOT_PARENT.first_child(network_interface.document_metadata()) {
Self {
network_interface,
next_layer: Some(first_layer),
parent_targets: vec![(LayerNodeIdentifier::ROOT_PARENT, target)],
}
} else {
Self {
network_interface,
next_layer: Default::default(),
parent_targets: Default::default(),
}
}
}