Check themes attribute exists before using it

Click "Restore default icons" before icon themes loaded will cause an error.
This commit is contained in:
xxyzz 2022-08-09 09:00:59 +08:00
parent cc58f2eda7
commit cfd24b8ff7
No known key found for this signature in database
GPG Key ID: F796163E6DCFEE9D

View File

@ -730,6 +730,8 @@ class ChooseThemeWidget(QWidget):
return default_theme() return default_theme()
def set_current_theme(self, name): def set_current_theme(self, name):
if not hasattr(self, "themes"):
return False
for i, t in enumerate(self.themes): for i, t in enumerate(self.themes):
if t.get('name') == name: if t.get('name') == name:
self.theme_list.setCurrentRow(i, QItemSelectionModel.SelectionFlag.SelectCurrent | QItemSelectionModel.SelectionFlag.Clear) self.theme_list.setCurrentRow(i, QItemSelectionModel.SelectionFlag.SelectCurrent | QItemSelectionModel.SelectionFlag.Clear)