Added better exception handling on Backup Cancel

Qt segfaults when the reject method throws an unhandled
exception; fixed that.
This commit is contained in:
Marta Marczykowska-Górecka 2019-10-17 21:22:01 +02:00
parent 4c2adbca00
commit 0d2d9970b7
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
2 changed files with 19 additions and 3 deletions

View File

@ -357,9 +357,15 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, QtWidgets.QWizard):
def reject(self): def reject(self):
if (self.currentPage() is self.commit_page) and \ if (self.currentPage() is self.commit_page) and \
self.button(self.CancelButton).isEnabled(): self.button(self.CancelButton).isEnabled():
self.qubes_app.qubesd_call( try:
'dom0', 'admin.backup.Cancel', self.qubes_app.qubesd_call(
backup_utils.get_profile_name(True)) 'dom0', 'admin.backup.Cancel',
backup_utils.get_profile_name(True))
except exc.QubesException as ex:
QtWidgets.QMessageBox.warning(
self, self.tr("Error cancelling backup!"),
self.tr("ERROR: {}").format(str(ex)))
self.thread.wait() self.thread.wait()
QtWidgets.QMessageBox.warning( QtWidgets.QMessageBox.warning(
self, self.tr("Backup aborted!"), self, self.tr("Backup aborted!"),

View File

@ -58,24 +58,28 @@ class VMSettingsTest(unittest.TestCase):
self.assertTrue( self.assertTrue(
self.dialog.tabWidget.currentWidget() is self.dialog.basic_tab) self.dialog.tabWidget.currentWidget() is self.dialog.basic_tab)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced")
self.assertTrue( self.assertTrue(
self.dialog.tabWidget.currentWidget() is self.dialog.advanced_tab) self.dialog.tabWidget.currentWidget() is self.dialog.advanced_tab)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="firewall") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="firewall")
self.assertTrue( self.assertTrue(
self.dialog.tabWidget.currentWidget() is self.dialog.firewall_tab) self.dialog.tabWidget.currentWidget() is self.dialog.firewall_tab)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="devices") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="devices")
self.assertTrue( self.assertTrue(
self.dialog.tabWidget.currentWidget() is self.dialog.devices_tab) self.dialog.tabWidget.currentWidget() is self.dialog.devices_tab)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, self.vm, qapp=self.qtapp, qubesapp=self.qapp,
@ -83,12 +87,14 @@ class VMSettingsTest(unittest.TestCase):
self.assertTrue( self.assertTrue(
self.dialog.tabWidget.currentWidget() is self.dialog.apps_tab) self.dialog.tabWidget.currentWidget() is self.dialog.apps_tab)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="services") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="services")
self.assertTrue( self.assertTrue(
self.dialog.tabWidget.currentWidget() is self.dialog.services_tab) self.dialog.tabWidget.currentWidget() is self.dialog.services_tab)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
def test_01_basic_tab_default(self): def test_01_basic_tab_default(self):
self.vm = self.qapp.add_new_vm("AppVM", "test-vm", "blue") self.vm = self.qapp.add_new_vm("AppVM", "test-vm", "blue")
@ -405,6 +411,7 @@ class VMSettingsTest(unittest.TestCase):
self.assertEqual(self.vm.maxmem, 0) self.assertEqual(self.vm.maxmem, 0)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced")
@ -457,6 +464,7 @@ class VMSettingsTest(unittest.TestCase):
self.assertEqual(self.vm.kernel, new_kernel) self.assertEqual(self.vm.kernel, new_kernel)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced")
@ -482,6 +490,7 @@ class VMSettingsTest(unittest.TestCase):
self.assertEqual(self.vm.virt_mode.upper(), mode) self.assertEqual(self.vm.virt_mode.upper(), mode)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced")
@ -502,6 +511,7 @@ class VMSettingsTest(unittest.TestCase):
self.assertEqual(self.vm.default_dispvm.name, new_dvm) self.assertEqual(self.vm.default_dispvm.name, new_dvm)
self.dialog.deleteLater() self.dialog.deleteLater()
self.qtapp.processEvents()
self.dialog = vm_settings.VMSettingsWindow( self.dialog = vm_settings.VMSettingsWindow(
self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced") self.vm, qapp=self.qtapp, qubesapp=self.qapp, init_page="advanced")