Disconnect from the device when opening a file or closing the app
Opening a file now drops the live connection once a file is chosen, without asking. File > Exit and the window close box go through quit_app, which closes the Sox session properly instead of leaving it for the device to time out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2435,6 +2435,30 @@ def do_device_disconnect():
|
||||
wiresheet.render_components([])
|
||||
|
||||
|
||||
def quit_app():
|
||||
"""File > Exit and the window's close box: let go of the device before going.
|
||||
|
||||
Leaving without a proper close keeps the device's Sox session and subscriptions
|
||||
alive until it times them out, so the next connect may be turned away.
|
||||
"""
|
||||
global _cov_poll_id
|
||||
|
||||
if _cov_poll_id is not None:
|
||||
app_state.window.after_cancel(_cov_poll_id)
|
||||
_cov_poll_id = None
|
||||
|
||||
ds = app_state.device_session
|
||||
app_state.device_session = None
|
||||
app_state.live_mode = False
|
||||
if ds is not None:
|
||||
try:
|
||||
ds.disconnect()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
app_state.window.destroy()
|
||||
|
||||
|
||||
def _start_cov_polling():
|
||||
"""Starts the 100ms COV event polling loop on the main thread."""
|
||||
global _cov_poll_id
|
||||
@@ -2616,7 +2640,7 @@ menu_file.add_command(label="Save As...", command=sax_file.save_file_as)
|
||||
menu_file.add_separator()
|
||||
menu_file.add_command(label="Print...", command=wiresheet.print_sheet, accelerator=f"{accel_mod}+P")
|
||||
menu_file.add_separator()
|
||||
menu_file.add_command(label="Exit", command=window.quit)
|
||||
menu_file.add_command(label="Exit", command=quit_app)
|
||||
menu_bar.add_cascade(label="File", menu=menu_file)
|
||||
|
||||
menu_edit = tk.Menu(menu_bar, tearoff=0)
|
||||
@@ -3000,6 +3024,8 @@ paned_window.add(frame_editor, weight=3)
|
||||
app_state.dirty_display_callback = refresh_dirty_display
|
||||
undo.set_refresh_callback(refresh_all_views)
|
||||
sax_file.set_tree_filled_callback(on_tree_filled)
|
||||
sax_file.set_disconnect_device_callback(do_device_disconnect)
|
||||
window.protocol("WM_DELETE_WINDOW", quit_app)
|
||||
refresh_palette_kits()
|
||||
apply_left_pane_width()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user