-
Notifications
You must be signed in to change notification settings - Fork 0
fix: ignore window close while a flash is in progress #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,19 @@ impl MainWindow { | |||||||||||||||||||||||||||||||||||||
| return Task::none(); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| iced::window::Event::CloseRequested => { | ||||||||||||||||||||||||||||||||||||||
| // Suppress the close while a flash is in progress so | ||||||||||||||||||||||||||||||||||||||
| // OpenOCD (or the FUS upgrade) isn't killed mid-write. | ||||||||||||||||||||||||||||||||||||||
| // The opacity overlay already signals the busy state | ||||||||||||||||||||||||||||||||||||||
| // visually; the user can SIGTERM 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: a flash is in progress." | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| // Suppress the close while a flash is in progress so | |
| // OpenOCD (or the FUS upgrade) isn't killed mid-write. | |
| // The opacity overlay already signals the busy state | |
| // visually; the user can SIGTERM 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: a flash is in progress." | |
| // Suppress the close while an operation is in progress | |
| // so tools such as OpenOCD (or the FUS upgrade) are | |
| // not interrupted mid-action. The opacity overlay | |
| // already signals the busy state visually; the user | |
| // can SIGTERM if they really need out, but a misclick | |
| // on the X should not interrupt an active operation. | |
| if self.tab_daplink.is_busy() || self.tab_ws.is_busy() { | |
| eprintln!( | |
| "Close request ignored: an operation is in progress." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c1ba41a — same fix as your other note: log/comment now say "operation in progress" instead of "flash in progress", consistent across both tabs and not misleading for the file-browse edge case.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,13 @@ pub struct TabDaplink { | |
| } | ||
|
|
||
| impl TabDaplink { | ||
| /// True while a flash sequence (or a file browse) is running. Used by | ||
| /// `MainWindow` to suppress window-close requests during a flash so the | ||
| /// OpenOCD child isn't killed mid-operation. | ||
| 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), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment suggests using SIGTERM as an escape hatch, but this app has Windows-specific code paths and SIGTERM isn’t generally applicable there. Consider rewording to a platform-neutral “force-quit / end task” phrasing to avoid confusion for Windows users and future maintainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in c1ba41a — applied your suggestion. SIGTERM dropped, replaced with "force-quit / end task" which is platform-neutral.