From f792a06f45e6acc04ca7a9042ee73cf9bf1f43ee Mon Sep 17 00:00:00 2001 From: z411 Date: Wed, 22 Aug 2018 20:39:43 -0300 Subject: [PATCH] Qt/GTK: Forgetting account whenever a fatal error occurs --- trackma/ui/gtkui.py | 6 ++++-- trackma/ui/qtui.py | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/trackma/ui/gtkui.py b/trackma/ui/gtkui.py index 52fc0036..316b555c 100644 --- a/trackma/ui/gtkui.py +++ b/trackma/ui/gtkui.py @@ -85,8 +85,10 @@ def main(self): Gtk.main() - def __do_switch_account(self, widget, switch=True): + def __do_switch_account(self, widget, switch=True, forget=False): manager = AccountManager() + if forget: + manager.set_default(None) self.accountsel = AccountSelect(manager = AccountManager(), switch=switch) self.accountsel.use_button.connect("clicked", self.use_account) self.accountsel.create() @@ -573,7 +575,7 @@ def idle_restart(self): def idle_restart_push(self): self.quit = False self.main.destroy() - self.__do_switch_account(None, False) + self.__do_switch_account(None, False, forget=True) def on_destroy(self, widget): if self.quit: diff --git a/trackma/ui/qtui.py b/trackma/ui/qtui.py index 63a24b6f..8c025afc 100644 --- a/trackma/ui/qtui.py +++ b/trackma/ui/qtui.py @@ -540,6 +540,7 @@ def error(self, msg): def fatal(self, msg): QMessageBox.critical(self, 'Fatal Error', "Fatal Error! Reason:\n\n{0}".format(msg), QMessageBox.Ok) + self.accountman.set_default(None) self._busy() self.finish = False self.worker_call('unload', self.r_engine_unloaded) @@ -1270,6 +1271,8 @@ def s_send(self, retrieve=False): def s_switch_account(self): if not self.accountman_widget: self.accountman_create() + else: + self.accountman_widget.update() self.accountman_widget.setModal(True) self.accountman_widget.show() @@ -2471,8 +2474,6 @@ def __init__(self, parent, accountman): bottom_layout = QHBoxLayout() self.remember_chk = QCheckBox('Remember') - if self.accountman.get_default() is not None: - self.remember_chk.setChecked(True) cancel_btn = QPushButton('Cancel') cancel_btn.clicked.connect(self.cancel) add_btn = QPushButton('Add') @@ -2504,6 +2505,7 @@ def __init__(self, parent, accountman): self.icons[libname] = QIcon(lib[1]) # Populate list + self.update() self.rebuild() # Finish layout @@ -2511,6 +2513,9 @@ def __init__(self, parent, accountman): layout.addLayout(bottom_layout) self.setLayout(layout) + def update(self): + self.remember_chk.setChecked(self.accountman.get_default() is not None) + def add(self): result = AccountAddDialog.do(icons=self.icons) if result: