Skip to content

Commit 47f4b12

Browse files
committed
fix(usage popup): Avoid tracebacks when main window gets closed before the usage popup
1 parent 02c0701 commit 47f4b12

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

ardupilot_methodic_configurator/frontend_tkinter_parameter_editor.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,16 @@ def __init__(self, configuration_manager: ConfigurationManager) -> None:
208208
self.root.update_idletasks()
209209
req_height = self.root.winfo_reqheight()
210210
self.root.geometry(f"990x{req_height}")
211+
212+
# Set up startup notification for the main application window
213+
FreeDesktop.setup_startup_notification(self.root) # type: ignore[arg-type]
214+
211215
# trigger a table update to ask the user what to do in the case this file needs special actions
212216
self.root.after(10, lambda: self.on_param_file_combobox_change(None, forced=True))
213217

214218
# this one should be on top of the previous one hence the longer time
215-
if UsagePopupWindow.should_display("parameter_editor"):
216-
self.root.after(100, self.__display_usage_popup_window(self.root)) # type: ignore[arg-type]
217-
218-
# Set up startup notification for the main application window
219-
FreeDesktop.setup_startup_notification(self.root) # type: ignore[arg-type]
219+
if isinstance(self.root, tk.Tk) and UsagePopupWindow.should_display("parameter_editor"):
220+
self.root.after(100, lambda: self.__display_usage_popup_window(self.root)) # type: ignore[arg-type]
220221

221222
self.root.mainloop()
222223

@@ -436,6 +437,9 @@ def __create_parameter_area_widgets(self) -> None:
436437

437438
@staticmethod
438439
def __display_usage_popup_window(parent: tk.Tk) -> None:
440+
if not parent.winfo_exists():
441+
return
442+
439443
usage_popup_window = BaseWindow(parent)
440444
style = ttk.Style()
441445

0 commit comments

Comments
 (0)