Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/ui/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ impl MainWindow {
return Task::none();
}
iced::window::Event::CloseRequested => {
// Suppress the close while an operation is in progress
// so OpenOCD (or the FUS upgrade) isn't interrupted
// mid-action. The opacity overlay already signals the
// busy state visually; the user can force-quit / end
// task the app if they really need out, but a misclick
// on the X shouldn't brick the device.
if self.tab_daplink.is_busy() || self.tab_ws.is_busy() {
eprintln!(
"Close request ignored: an operation is in progress."
);
return Task::none();
}

match dirs::get_settings_dir() {
Ok(settings_dir) => {
let fields_file = settings_dir.join(SETTINGS_FILE);
Expand Down
8 changes: 8 additions & 0 deletions src/ui/tab_daplink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub struct TabDaplink {
}

impl TabDaplink {
/// True while an operation that should not be interrupted is running:
/// a flash sequence, or a (modal) file-browse. Used by `MainWindow` to
/// suppress window-close requests so the OpenOCD child isn't killed
/// mid-write.
pub fn is_busy(&self) -> bool {
self.is_readonly
}

pub fn update(&mut self, message: TabDaplinkMessage) -> Task<Message> {
match message {
TabDaplinkMessage::LogMessage(log) => self.log_widget.push(log),
Expand Down
7 changes: 7 additions & 0 deletions src/ui/tab_wireless_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ const ALL_STACK: [WirelessStackFile; 21] = [
];

impl TabWirelessStack {
/// True while an operation that should not be interrupted is running.
/// Used by `MainWindow` to suppress window-close requests so neither
/// the OpenOCD child nor an in-flight FUS upgrade gets cut mid-action.
pub fn is_busy(&self) -> bool {
self.is_readonly
}

pub fn view(&self) -> Element<Message> {
let grid_fields = grid!(
grid_row!(
Expand Down
Loading