Fix stuck outline overlay (#925)

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube 2022-12-28 20:21:13 +00:00 committed by Keavon Chambers
parent 3bce11edb5
commit af7779769a

View file

@ -21,7 +21,7 @@ pub struct PathOutline {
impl PathOutline {
/// Creates an outline of a layer either with a pre-existing overlay or by generating a new one
fn create_outline(
fn try_create_outline(
document_layer_path: Vec<LayerId>,
overlay_path: Option<Vec<LayerId>>,
document: &DocumentMessageHandler,
@ -72,6 +72,28 @@ impl PathOutline {
Some(overlay)
}
/// Creates an outline of a layer either with a pre-existing overlay or by generating a new one
///
/// Creates an outline, discarding the overlay on failiure
fn create_outline(
document_layer_path: Vec<LayerId>,
overlay_path: Option<Vec<LayerId>>,
document: &DocumentMessageHandler,
responses: &mut VecDeque<Message>,
font_cache: &FontCache,
) -> Option<Vec<LayerId>> {
let copied_overlay_path = overlay_path.clone();
let result = Self::try_create_outline(document_layer_path, overlay_path, document, responses, font_cache);
if result.is_none() {
// Discard the overlay layer if it exists
if let Some(overlay_path) = copied_overlay_path {
let operation = Operation::DeleteLayer { path: overlay_path };
responses.push_back(DocumentMessage::Overlays(operation.into()).into());
}
}
result
}
/// Removes the hovered overlay and deletes path references
pub fn clear_hovered(&mut self, responses: &mut VecDeque<Message>) {
if let Some(path) = self.hovered_overlay_path.take() {