From c198108700df9aa6b9fa0438219e505e71c1afd5 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Mon, 10 Jun 2024 12:55:58 -0400 Subject: [PATCH] [748] Establish EDMC Shutdown Mechanism --- EDMarketConnector.py | 12 +++++++++++- prefs.py | 18 +++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index cd76ccc0..2582f570 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -845,9 +845,19 @@ class AppWindow: ) update_msg = update_msg.replace('\\n', '\n') update_msg = update_msg.replace('\\r', '\r') - stable_popup = tk.messagebox.askyesno(title=title, message=update_msg, parent=postargs.get('Parent')) + stable_popup = tk.messagebox.askyesno(title=title, message=update_msg) if stable_popup: webbrowser.open("https://github.com/edCD/eDMarketConnector/releases/latest") + if postargs.get('Restart_Req'): + restart_msg = tr.tl('A restart of EDMC is required. EDMC will now shut down.') + restart_box = tk.messagebox.Message( + title=tr.tl('Restart Required'), + message=restart_msg, + type=tk.messagebox.OK + ) + restart_box.show() + if restart_box: + app.onexit() def set_labels(self): """Set main window labels, e.g. after language change.""" diff --git a/prefs.py b/prefs.py index 9f2062f4..dffe71b9 100644 --- a/prefs.py +++ b/prefs.py @@ -239,6 +239,7 @@ class PreferencesDialog(tk.Toplevel): self.parent = parent self.callback = callback + self.req_restart = False # LANG: File > Settings (macOS) self.title(tr.tl('Settings')) @@ -1274,19 +1275,22 @@ class PreferencesDialog(tk.Toplevel): config.set('dark_highlight', self.theme_colors[1]) theme.apply(self.parent) - # Send to the Post Config if we updated the update branch - post_flags = { - 'Update': True if self.curr_update_track != self.update_paths.get() else False, - 'Track': self.update_paths.get(), - 'Parent': self - } # Notify if self.callback: - self.callback(**post_flags) + self.callback() plug.notify_prefs_changed(monitor.cmdr, monitor.is_beta) self._destroy() + # Send to the Post Config if we updated the update branch or need to restart + post_flags = { + 'Update': True if self.curr_update_track != self.update_paths.get() else False, + 'Track': self.update_paths.get(), + 'Parent': self, + 'Restart_Req': True if self.req_restart else False + } + if self.callback: + self.callback(**post_flags) def _destroy(self) -> None: """widget.destroy wrapper that does some extra cleanup."""