Outdated state cleanup

Fixes problems showing 'outdated' instead 'to-be-outdated' when template is running

Fixes the removal of the icon calling setVisible(False) before removeWidget()
This commit is contained in:
donoban 2018-05-09 19:39:41 +02:00
parent e2fccf592a
commit 224c8708fc
No known key found for this signature in database
GPG Key ID: 141310D8E3ED08A5

View File

@ -376,24 +376,25 @@ class VmUpdateInfoWidget(QtGui.QWidget):
self.update_outdated()
def update_outdated(self):
outdated_state = False
if self.vm.is_running():
outdated_state = False
for vol in self.vm.volumes.values():
if vol.is_outdated():
outdated_state = "outdated"
break
if not outdated_state and getattr(self.vm, 'template', None)\
and self.vm.template.is_running():
if hasattr(self.vm, 'template') and self.vm.template.is_running():
outdated_state = "to-be-outdated"
if outdated_state != self.previous_outdated_state:
self.update_status_widget(outdated_state)
self.previous_outdated_state = outdated_state
else:
outdated_state = False
if not outdated_state:
for vol in self.vm.volumes.values():
if vol.is_outdated():
outdated_state = "outdated"
break
self.update_status_widget(outdated_state)
def update_status_widget(self, state):
if state == self.previous_outdated_state:
return
self.previous_outdated_state = state
self.value = state
self.table_item.set_value(state)
if state == "update":
@ -413,22 +414,18 @@ class VmUpdateInfoWidget(QtGui.QWidget):
"The Template must be stopped before changes from its "
"current session can be picked up by this qube.")
else:
label_text = ""
icon_path = None
tooltip_text = None
if self.show_text:
self.label.setText(label_text)
else:
if hasattr(self, 'icon'):
self.icon.setVisible(False)
self.layout().removeWidget(self.icon)
self.icon.deleteLater()
if icon_path is not None:
self.icon = VmIconWidget(icon_path, True, 0.7)
self.icon.setToolTip(tooltip_text)
else:
self.icon = QtGui.QLabel(label_text)
self.layout().addWidget(self.icon, alignment=QtCore.Qt.AlignCenter)
del self.icon
if icon_path is not None:
self.icon = VmIconWidget(icon_path, True, 0.7)
self.icon.setToolTip(tooltip_text)
self.layout().addWidget(self.icon, alignment=QtCore.Qt.AlignCenter)
self.icon.setVisible(True)
class VmSizeOnDiskItem(QtGui.QTableWidgetItem):
def __init__(self, vm):