Skip to content

Commit

Permalink
Qt/GTK: Forgetting account whenever a fatal error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
z411 committed Aug 22, 2018
1 parent b65eaa1 commit f792a06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions trackma/ui/gtkui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions trackma/ui/qtui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -2504,13 +2505,17 @@ def __init__(self, parent, accountman):
self.icons[libname] = QIcon(lib[1])

# Populate list
self.update()
self.rebuild()

# Finish layout
layout.addWidget(self.table)
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:
Expand Down

0 comments on commit f792a06

Please sign in to comment.