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:
+13
@@ -126,6 +126,19 @@ def open_file():
|
||||
messagebox.showwarning("Action Blocked", "Cannot load SAX profiles because 'Sedona home folder' configuration is missing or empty.")
|
||||
return
|
||||
|
||||
if app_state.live_mode:
|
||||
answer = messagebox.askyesnocancel(
|
||||
"Device Connected",
|
||||
"A live device connection is active.\n\n"
|
||||
"Disconnect from the device and open a file?\n\n"
|
||||
"Choose Yes to disconnect and open, No to cancel.",
|
||||
)
|
||||
if not answer:
|
||||
return
|
||||
# Import here to avoid circular import at module level
|
||||
from main import do_device_disconnect
|
||||
do_device_disconnect()
|
||||
|
||||
file_path = filedialog.askopenfilename(
|
||||
title="Select SAX File",
|
||||
filetypes=[("SAX Files", "*.sax"), ("XML Files", "*.xml"), ("All Files", "*.*")],
|
||||
|
||||
Reference in New Issue
Block a user