Added exceptions for domain add and remove
This commit is contained in:
parent
8327e32e1f
commit
b5808296bf
@ -408,28 +408,30 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
|
|||||||
row_no = self.table.rowCount()
|
row_no = self.table.rowCount()
|
||||||
self.table.setRowCount(row_no + 1)
|
self.table.setRowCount(row_no + 1)
|
||||||
|
|
||||||
|
|
||||||
for vm in self.qubes_app.domains:
|
for vm in self.qubes_app.domains:
|
||||||
if vm.qid == qid:
|
if vm.qid == qid:
|
||||||
vm_row = VmRowInTable(vm, row_no, self.table)
|
vm_row = VmRowInTable(vm, row_no, self.table)
|
||||||
self.vms_in_table[vm.qid] = vm_row
|
self.vms_in_table[vm.qid] = vm_row
|
||||||
break
|
self.table.setSortingEnabled(True)
|
||||||
|
return
|
||||||
|
|
||||||
self.table.setSortingEnabled(True)
|
# Never should reach here
|
||||||
|
raise RuntimeError('Added domain not found')
|
||||||
|
|
||||||
def onDomainRemoved(self, _, domain):
|
def onDomainRemoved(self, _, domain):
|
||||||
#needs to clear cache
|
#needs to clear cache
|
||||||
self.qubes_app.domains.clear_cache()
|
self.qubes_app.domains.clear_cache()
|
||||||
|
|
||||||
qid = int(domain.split('/')[-1])
|
qid = int(domain.split('/')[-1])
|
||||||
|
|
||||||
# Find row and remove
|
# Find row and remove
|
||||||
row_index = 0
|
try:
|
||||||
vm_item = self.table.item(row_index, self.columns_indices["Name"])
|
row_index = 0
|
||||||
while vm_item.qid != qid:
|
|
||||||
row_index += 1
|
|
||||||
vm_item = self.table.item(row_index, self.columns_indices["Name"])
|
vm_item = self.table.item(row_index, self.columns_indices["Name"])
|
||||||
|
while vm_item.qid != qid:
|
||||||
|
row_index += 1
|
||||||
|
vm_item = self.table.item(row_index, self.columns_indices["Name"])
|
||||||
|
except:
|
||||||
|
raise RuntimeError('Deleted domain not found')
|
||||||
|
|
||||||
self.table.removeRow(row_index)
|
self.table.removeRow(row_index)
|
||||||
del self.vms_in_table[qid]
|
del self.vms_in_table[qid]
|
||||||
|
Loading…
Reference in New Issue
Block a user