mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 19:08:05 +08:00
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:
@@ -991,6 +991,7 @@ impl MessageHandler<DocumentMessage, (&InputPreprocessorMessageHandler, &FontCac
|
||||
}
|
||||
DeleteLayer { layer_path } => {
|
||||
responses.push_front(DocumentOperation::DeleteLayer { path: layer_path.clone() }.into());
|
||||
responses.push_front(ToolMessage::AbortCurrentTool.into());
|
||||
responses.push_back(PropertiesPanelMessage::CheckSelectedWasDeleted { path: layer_path }.into());
|
||||
}
|
||||
DeleteSelectedLayers => {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user