From 19b9ffefdac6347648f62e9b33f0ed2ccdb1f794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 2 Oct 2013 01:10:58 +0200 Subject: [PATCH] Catch the exception on device attach/detach Take care to release lock before anything else, otherwise GUI will be frozen... --- qubesmanager/main.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qubesmanager/main.py b/qubesmanager/main.py index 8497c96..e6d57a5 100755 --- a/qubesmanager/main.py +++ b/qubesmanager/main.py @@ -1847,11 +1847,15 @@ class VmManagerWindow(Ui_VmManagerWindow, QMainWindow): vm = self.get_selected_vm() self.blk_manager.blk_lock.acquire() - if dev in self.blk_manager.attached_devs: - self.blk_manager.detach_device(vm, dev) - else: - self.blk_manager.attach_device(vm, dev) - self.blk_manager.blk_lock.release() + try: + if dev in self.blk_manager.attached_devs: + self.blk_manager.detach_device(vm, dev) + else: + self.blk_manager.attach_device(vm, dev) + self.blk_manager.blk_lock.release() + except QubesException as e: + self.blk_manager.blk_lock.release() + QMessageBox.critical(None, "Block attach/detach error!", str(e)) class QubesBlockDevicesManager():