diff --git a/src/bin/topola-egui/menu_bar.rs b/src/bin/topola-egui/menu_bar.rs index 480a25d..65166d4 100644 --- a/src/bin/topola-egui/menu_bar.rs +++ b/src/bin/topola-egui/menu_bar.rs @@ -324,8 +324,7 @@ impl MenuBar { arc_mutex_maybe_invoker.lock().unwrap().as_mut(), maybe_overlay, ) { - let selection = overlay.selection().clone(); - overlay.clear_selection(); + let selection = overlay.take_selection(); *maybe_activity = Some(ActivityStepperWithStatus::new_execution( invoker.execute_stepper(Command::RemoveBands( selection.band_selection, @@ -342,8 +341,7 @@ impl MenuBar { arc_mutex_maybe_invoker.lock().unwrap().as_mut(), maybe_overlay, ) { - let selection = overlay.selection().clone(); - overlay.clear_selection(); + let selection = overlay.take_selection(); *maybe_activity = Some(ActivityStepperWithStatus::new_execution( invoker.execute_stepper(Command::Autoroute( selection.pin_selection, @@ -360,8 +358,7 @@ impl MenuBar { arc_mutex_maybe_invoker.lock().unwrap().as_mut(), maybe_overlay, ) { - let selection = overlay.selection().clone(); - overlay.clear_selection(); + let selection = overlay.take_selection(); *maybe_activity = Some(ActivityStepperWithStatus::new_execution( invoker.execute_stepper(Command::CompareDetours( selection.pin_selection, @@ -378,8 +375,7 @@ impl MenuBar { arc_mutex_maybe_invoker.lock().unwrap().as_mut(), maybe_overlay, ) { - let selection = overlay.selection().clone(); - overlay.clear_selection(); + let selection = overlay.take_selection(); *maybe_activity = Some(ActivityStepperWithStatus::new_execution( invoker.execute_stepper(Command::MeasureLength( selection.band_selection, diff --git a/src/bin/topola-egui/overlay.rs b/src/bin/topola-egui/overlay.rs index 394cfc4..74efa8b 100644 --- a/src/bin/topola-egui/overlay.rs +++ b/src/bin/topola-egui/overlay.rs @@ -36,6 +36,10 @@ impl Overlay { }) } + pub fn take_selection(&mut self) -> Selection { + core::mem::replace(&mut self.selection, Selection::new()) + } + pub fn clear_selection(&mut self) { self.selection = Selection::new(); }