Fix error on reverting Qube Manager to an older version

In rare case (when the Qube Manager was reverted to an older version
that does not have a column on which it was last sorted) downgrading
Qube Manager could result in a crash on start.
This commit is contained in:
Marta Marczykowska-Górecka 2019-04-03 20:39:40 +02:00
parent ee8bce269f
commit d2ad60edd2
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B

View File

@ -608,8 +608,16 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtGui.QMainWindow):
self.sort_order = QtCore.Qt.SortOrder(
self.manager_settings.value("view/sort_order",
defaultValue=self.sort_order))
self.table.sortItems(self.columns_indices[self.sort_by_column],
self.sort_order)
try:
self.table.sortItems(self.columns_indices[self.sort_by_column],
self.sort_order)
except KeyError:
# the manager was sorted on a column that does not exist in the
# current version; possible only with downgrades
self.table.sortItems(self.columns_indices["Name"],
self.sort_order)
if not self.manager_settings.value("view/menubar_visible",
defaultValue=True):
self.action_menubar.setChecked(False)