Guard file open and device connect against conflicting state

Opening a file while connected to a device prompts to disconnect first.
Connecting to a device while a file is open prompts to save unsaved
changes, then closes the file before showing the connect dialog.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-12 13:58:55 +03:00
co-authored by Claude Opus 4.6
parent 89aab50948
commit e33a6bc5d8
3 changed files with 30 additions and 1 deletions
+16
View File
@@ -1927,6 +1927,22 @@ _cov_poll_id = None
def do_device_connect():
"""Opens the connect dialog and initiates a device connection."""
if app_state.current_file_path and not app_state.live_mode:
if app_state.is_dirty:
answer = messagebox.askyesnocancel(
"Unsaved Changes",
"The current file has unsaved changes.\n\n"
"Save before connecting to a device?",
)
if answer is None:
return
if answer:
sax_file.execute_direct_overwrite_save()
sax_file.reset_to_startup_state()
sax_file.refresh_treeview_from_dom(None)
wiresheet.render_components([])
app_state.window.title(app_state.base_window_title())
connect_dialog.ConnectDialog(app_state.window, _connect_to_device)