Added try/except for all __lt__() methods since some VM could be deleted
before the signal is received and handled. It fixes renaming a VM and deleting two domains at same time.
This commit is contained in:
parent
85dc0f9083
commit
ae23443608
@ -961,7 +961,13 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
||||
settings_window = settings.VMSettingsWindow(
|
||||
vm, self.qt_app, "basic")
|
||||
settings_window.exec_()
|
||||
|
||||
# vm could be deleted on renaming
|
||||
try:
|
||||
self.vms_in_table[vm.qid].update()
|
||||
except exc.QubesPropertyAccessError:
|
||||
pass
|
||||
|
||||
|
||||
# noinspection PyArgumentList
|
||||
@QtCore.pyqtSlot(name='on_action_appmenus_triggered')
|
||||
|
@ -24,6 +24,8 @@ from PyQt4 import QtGui # pylint: disable=import-error
|
||||
from PyQt4 import QtCore # pylint: disable=import-error
|
||||
# pylint: disable=too-few-public-methods
|
||||
|
||||
from qubesadmin import exc
|
||||
|
||||
power_order = QtCore.Qt.DescendingOrder
|
||||
update_order = QtCore.Qt.AscendingOrder
|
||||
|
||||
@ -74,6 +76,7 @@ class VmTypeWidget(VmIconWidget):
|
||||
self.value = value
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -81,6 +84,8 @@ class VmTypeWidget(VmIconWidget):
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
def __init__(self, vm, parent=None):
|
||||
(icon_path, tooltip) = self.get_vm_icon(vm)
|
||||
@ -120,6 +125,7 @@ class VmLabelWidget(VmIconWidget):
|
||||
self.value = value
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -127,6 +133,8 @@ class VmLabelWidget(VmIconWidget):
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
def __init__(self, vm, parent=None):
|
||||
icon_path = self.get_vm_icon_path(vm)
|
||||
@ -149,11 +157,14 @@ class VmNameItem(QtGui.QTableWidgetItem):
|
||||
self.qid = vm.qid
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.qid == 0:
|
||||
return True
|
||||
elif other.qid == 0:
|
||||
return False
|
||||
return super(VmNameItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
|
||||
class VmStatusIcon(QtGui.QLabel):
|
||||
@ -193,10 +204,13 @@ class VmInfoWidget(QtGui.QWidget):
|
||||
|
||||
def __lt__(self, other):
|
||||
# pylint: disable=too-many-return-statements
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
self_val = self.upd_info_item.value
|
||||
other_val = other.upd_info_item.value
|
||||
@ -278,6 +292,7 @@ class VmTemplateItem(QtGui.QTableWidgetItem):
|
||||
self.setText(self.vm.klass)
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -285,6 +300,8 @@ class VmTemplateItem(QtGui.QTableWidgetItem):
|
||||
elif self.text() == other.text():
|
||||
return self.vm.name < other.vm.name
|
||||
return super(VmTemplateItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
|
||||
class VmNetvmItem(QtGui.QTableWidgetItem):
|
||||
@ -302,6 +319,7 @@ class VmNetvmItem(QtGui.QTableWidgetItem):
|
||||
self.setText(self.vm.netvm.name)
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -309,6 +327,8 @@ class VmNetvmItem(QtGui.QTableWidgetItem):
|
||||
elif self.text() == other.text():
|
||||
return self.vm.name < other.vm.name
|
||||
return super(VmNetvmItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
|
||||
class VmInternalItem(QtGui.QTableWidgetItem):
|
||||
@ -325,11 +345,14 @@ class VmInternalItem(QtGui.QTableWidgetItem):
|
||||
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
return super(VmInternalItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
|
||||
# features man qvm-features
|
||||
@ -350,6 +373,7 @@ class VmUpdateInfoWidget(QtGui.QWidget):
|
||||
self.value = 0
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -357,6 +381,8 @@ class VmUpdateInfoWidget(QtGui.QWidget):
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
def __init__(self, vm, show_text=True, parent=None):
|
||||
super(VmUpdateInfoWidget, self).__init__(parent)
|
||||
@ -457,6 +483,7 @@ class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
|
||||
self.setText(str(self.value) + " MiB")
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -464,6 +491,8 @@ class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
|
||||
elif self.value == other.value:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.value < other.value
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
|
||||
class VmIPItem(QtGui.QTableWidgetItem):
|
||||
@ -479,11 +508,14 @@ class VmIPItem(QtGui.QTableWidgetItem):
|
||||
self.setText(self.ip if self.ip is not None else 'n/a')
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
return False
|
||||
return super(VmIPItem, self).__lt__(other)
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
|
||||
class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
||||
@ -501,6 +533,7 @@ class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
||||
self.setText("")
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -508,6 +541,8 @@ class VmIncludeInBackupsItem(QtGui.QTableWidgetItem):
|
||||
elif self.vm.include_in_backups == other.vm.include_in_backups:
|
||||
return self.vm.name < other.vm.name
|
||||
return self.vm.include_in_backups < other.vm.include_in_backups
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
||||
|
||||
class VmLastBackupItem(QtGui.QTableWidgetItem):
|
||||
@ -528,6 +563,7 @@ class VmLastBackupItem(QtGui.QTableWidgetItem):
|
||||
self.setText("")
|
||||
|
||||
def __lt__(self, other):
|
||||
try:
|
||||
if self.vm.qid == 0:
|
||||
return True
|
||||
elif other.vm.qid == 0:
|
||||
@ -539,3 +575,5 @@ class VmLastBackupItem(QtGui.QTableWidgetItem):
|
||||
elif not other.backup_timestamp:
|
||||
return True
|
||||
return self.backup_timestamp < other.backup_timestamp
|
||||
except exc.QubesPropertyAccessError:
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user