commit eb865779eb8181df0bfab9545c2150dfa9c5d22a
parent f6200bd73ed579eba154dfb90fc3820a7d7b5323
Author: Neil Booth <kyuupichan@gmail.com>
Date: Sat, 23 Jan 2016 12:11:07 +0900
Small fix for trezor devices
Client operations are asynchronous; do any unpairing after
the operation.
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/plugins/trezor/qt_generic.py b/plugins/trezor/qt_generic.py
@@ -320,12 +320,16 @@ class SettingsDialog(WindowModalDialog):
self.current_label=None
def invoke_client(method, *args, **kw_args):
+ unpair_after = kw_args.pop('unpair_after', False)
+
def task():
client = devmgr.client_by_id(device_id, handler)
if not client:
raise RuntimeError("Device not connected")
if method:
getattr(client, method)(*args, **kw_args)
+ if unpair_after:
+ devmgr.unpair_id(device_id)
return client.features
thread.add(task, on_success=update)
@@ -378,8 +382,7 @@ class SettingsDialog(WindowModalDialog):
"Are you sure you want to proceed?") % plugin.device
if not self.question(msg, title=title):
return
- invoke_client('toggle_passphrase')
- devmgr.unpair_id(device_id)
+ invoke_client('toggle_passphrase', unpair_after=True)
def change_homescreen():
from PIL import Image # FIXME
@@ -416,8 +419,7 @@ class SettingsDialog(WindowModalDialog):
if not self.question(msg, title=title,
icon=QMessageBox.Critical):
return
- invoke_client('wipe_device')
- devmgr.unpair_id(device_id)
+ invoke_client('wipe_device', unpair_after=True)
def slider_moved():
mins = timeout_slider.sliderPosition()