From 7f15cac5e2509e26af11aa5f2ebdc16154dae10b Mon Sep 17 00:00:00 2001 From: mfish33 <32677537+mfish33@users.noreply.github.com> Date: Sun, 26 Jun 2022 22:25:28 -0600 Subject: [PATCH] Fix crash on document switch (#690) fix crash on unwrap --- editor/src/document/transformation.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/editor/src/document/transformation.rs b/editor/src/document/transformation.rs index a6d34eea..f198c9c9 100644 --- a/editor/src/document/transformation.rs +++ b/editor/src/document/transformation.rs @@ -264,13 +264,16 @@ impl<'a> Selected<'a> { pub fn revert_operation(&mut self) { for path in self.selected { - self.responses.push_back( - DocumentOperation::SetLayerTransform { - path: path.to_vec(), - transform: (*self.original_transforms.get(*path).unwrap()).to_cols_array(), - } - .into(), - ); + if let Some(transform) = self.original_transforms.get(*path) { + // Push front to stop document switching before sending the transform + self.responses.push_front( + DocumentOperation::SetLayerTransform { + path: path.to_vec(), + transform: transform.to_cols_array(), + } + .into(), + ); + } } } }