Skip to content

Commit

Permalink
main_window: fix recursive ui locking in flasher
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzz committed Apr 20, 2022
1 parent 367c888 commit 13c730d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/main/python/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def __init__(self, appctx):
super().__init__()
self.appctx = appctx

self.ui_lock_count = 0

self.settings = QSettings("Vial", "Vial")
if self.settings.value("size", None) and self.settings.value("pos", None):
self.resize(self.settings.value("size"))
Expand Down Expand Up @@ -332,16 +334,20 @@ def on_load_dummy(self):
self.autorefresh.load_dummy(data)

def lock_ui(self):
self.autorefresh._lock()
self.tabs.setEnabled(False)
self.combobox_devices.setEnabled(False)
self.btn_refresh_devices.setEnabled(False)
self.ui_lock_count += 1
if self.ui_lock_count == 1:
self.autorefresh._lock()
self.tabs.setEnabled(False)
self.combobox_devices.setEnabled(False)
self.btn_refresh_devices.setEnabled(False)

def unlock_ui(self):
self.autorefresh._unlock()
self.tabs.setEnabled(True)
self.combobox_devices.setEnabled(True)
self.btn_refresh_devices.setEnabled(True)
self.ui_lock_count -= 1
if self.ui_lock_count == 0:
self.autorefresh._unlock()
self.tabs.setEnabled(True)
self.combobox_devices.setEnabled(True)
self.btn_refresh_devices.setEnabled(True)

def unlock_keyboard(self):
if isinstance(self.autorefresh.current_device, VialKeyboard):
Expand Down

0 comments on commit 13c730d

Please sign in to comment.