Trezor: GUI fixes
Trezor window was doing GUI stuff outside the GUI thread
This commit is contained in:
parent
24037be99c
commit
0d14781463
|
@ -281,6 +281,10 @@ class DeviceMgr(PrintError):
|
|||
self.recognised_hardware.add(pair)
|
||||
|
||||
def create_client(self, device, handler, plugin):
|
||||
# Get from cache first
|
||||
client = self.client_lookup(device.id_)
|
||||
if client:
|
||||
return client
|
||||
client = plugin.create_client(device, handler)
|
||||
if client:
|
||||
self.print_error("Registering", client)
|
||||
|
@ -301,6 +305,8 @@ class DeviceMgr(PrintError):
|
|||
|
||||
def unpair_wallet(self, wallet):
|
||||
with self.lock:
|
||||
if not wallet in self.wallets:
|
||||
return
|
||||
wallet_id = self.wallets.pop(wallet)
|
||||
client = self.client_lookup(wallet_id)
|
||||
self.clients.pop(client, None)
|
||||
|
@ -322,6 +328,10 @@ class DeviceMgr(PrintError):
|
|||
def paired_wallets(self):
|
||||
return list(self.wallets.keys())
|
||||
|
||||
def unpaired_devices(self, handler):
|
||||
devices = self.scan_devices(handler)
|
||||
return [dev for dev in devices if not self.wallet_by_id(dev.id_)]
|
||||
|
||||
def client_lookup(self, id_):
|
||||
with self.lock:
|
||||
for client, (path, client_id) in self.clients.items():
|
||||
|
|
|
@ -314,13 +314,14 @@ class TrezorCompatiblePlugin(BasePlugin, ThreadJob):
|
|||
devmgr = self.device_manager()
|
||||
devices = devmgr.unpaired_devices(handler)
|
||||
|
||||
states = [_("wiped"), _("initialized")]
|
||||
good_devices, descrs = [], []
|
||||
for device in devices:
|
||||
client = self.device_manager().create_client(device, handler, self)
|
||||
if not client:
|
||||
continue
|
||||
state = states[client.is_initialized()]
|
||||
label = device.info['label'] or _("An unnamed device")
|
||||
label = client.label() or _("An unnamed device")
|
||||
good_devices.append(device)
|
||||
descrs.append("%s: device ID %s (%s)" % (label, device.id_, state))
|
||||
|
||||
|
|
|
@ -312,9 +312,9 @@ class SettingsDialog(WindowModalDialog):
|
|||
raise RuntimeError("Device not connected")
|
||||
if method:
|
||||
getattr(client, method)(*args, **kw_args)
|
||||
update(client.features)
|
||||
return client.features
|
||||
|
||||
thread.add(task)
|
||||
thread.add(task, on_success=update)
|
||||
|
||||
def update(features):
|
||||
self.current_label = features.label
|
||||
|
|
Loading…
Reference in New Issue