Fix layer deletion bugs when tools are in use (#684)

* Added test case of layer delete bug

* Fixed crash in `PenTool`

Updated the document `MessageHandler` to cancel all active tools if the
layer is deleted.  This prevents the tools from crashing due to the
layer being pulled from under them.

* Moved Abort into pre-graphene DeleteLayer message

* Renamed test case for clarity

* Moved tool crash tests to the `tools` module

* Added `test-case` to the dev dependencies

* Added crash test case for all tools

* Ran cargo fmt

Co-authored-by: otdavies <oliver@psyfer.io>
Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Alexi
2022-06-24 09:35:07 -05:00
committed by GitHub
co-authored by otdavies Keavon Chambers
parent a4a174db04
commit 8f4cb882a9
5 changed files with 89 additions and 1 deletions
+5 -1
View File
@@ -199,7 +199,11 @@ impl<'a> Selected<'a> {
pub fn new(original_transforms: &'a mut OriginalTransforms, pivot: &'a mut DVec2, selected: &'a [&'a Vec<LayerId>], responses: &'a mut VecDeque<Message>, document: &'a Document) -> Self {
for path in selected {
if !original_transforms.contains_key(*path) {
original_transforms.insert(path.to_vec(), document.layer(path).unwrap().transform);
if let Ok(layer) = document.layer(path) {
original_transforms.insert(path.to_vec(), layer.transform);
} else {
log::warn!("Didn't find a layer for {:?}", path);
}
}
}
Self {