Fixed most crashes

This commit is contained in:
otdavies
2022-01-02 01:50:10 -08:00
parent 3a74f44d86
commit 763a1c5a5d
4 changed files with 43 additions and 14 deletions
+4
View File
@@ -140,6 +140,10 @@ impl Document {
path
}
pub fn is_folder(&self, path: &[LayerId]) -> bool {
return self.folder(path).is_ok();
}
// Determines which layer is closer to the root, if path_a return true, if path_b return false
// Answers the question: Is A closer to the root than B?
pub fn layer_closer_to_root(&self, path_a: &[u64], path_b: &[u64]) -> bool {
+5
View File
@@ -101,6 +101,11 @@ impl Folder {
Some(&mut self.layers[pos])
}
pub fn folder_contains(&self, id: LayerId) -> bool {
log::debug!("For {:?} Folder does contain {:?}", id, self.layer_ids.contains(&id));
self.layer_ids.contains(&id)
}
pub fn position_of_layer(&self, layer_id: LayerId) -> Result<usize, DocumentError> {
self.layer_ids.iter().position(|x| *x == layer_id).ok_or_else(|| DocumentError::LayerNotFound([layer_id].into()))
}