macOS: handle quit event properly

quit currently exits without saving settings, this fixes that issue
This commit is contained in:
Morgan Harris 2023-10-11 14:07:48 +11:00
parent eeb24fcf61
commit 3777346aa0

11
UVR.py
View File

@ -2247,6 +2247,12 @@ class MainWindow(TkinterDnD.Tk if is_dnd_compatible else tk.Tk):
if confirm: if confirm:
self.save_values(app_close=True, is_restart=True) self.save_values(app_close=True, is_restart=True)
def quit(self):
self.save_values(app_close=True)
super().quit()
def delete_temps(self, is_start_up=False): def delete_temps(self, is_start_up=False):
"""Deletes temp files""" """Deletes temp files"""
@ -7195,6 +7201,11 @@ if __name__ == "__main__":
root.is_root_defined_var.set(True) root.is_root_defined_var.set(True)
root.is_check_splash = True root.is_check_splash = True
# macOS - intercept the Quit event to make sure we save our preferences
# the default implementation completely shortcuts python and directly exits the process
# even atexit handlers are not called!
root.createcommand('tk::mac::Quit', root.quit)
root.update() if is_windows else root.update_idletasks() root.update() if is_windows else root.update_idletasks()
root.deiconify() root.deiconify()
root.configure(bg=BG_COLOR) root.configure(bg=BG_COLOR)