From 75532fb2ff30fb68ec30e97a1af7c19a3fbf7b77 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Mon, 12 Sep 2011 21:15:35 -0700 Subject: [PATCH] Bug fix: Don't break when using non-existant theme --- CHANGELOG.mkdn | 1 + TODO.mkdn | 1 - menus.py | 3 ++- profile.py | 11 ++++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.mkdn b/CHANGELOG.mkdn index 68b5fe9..3d82365 100644 --- a/CHANGELOG.mkdn +++ b/CHANGELOG.mkdn @@ -39,6 +39,7 @@ CHANGELOG * Alt characters don't break on random replace - Kiooeht [evacipatedBox] * Trollian 2.5 tray icon is now Trollian icon - Kiooeht [evacipatedBox] * Don't screw up tags with the mispeller - Kiooeht [evacipatedBox] + * Don't break if profile uses non-existant theme - Kiooeht [evacipatedBox] * Mac Bug fixes * Create all datadir stuff - Lexi [lexicalNuance] diff --git a/TODO.mkdn b/TODO.mkdn index cfa38b0..afb3897 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -33,7 +33,6 @@ Bugs * Closing a timeclone doesn't actually cease for everyone else * Kill Zalgo * Random invisible, tiny links to last link at end of every message -* Profiles using themes you don't have break everything Windows Bugs ------------ diff --git a/menus.py b/menus.py index 111c99f..7e5a6b8 100644 --- a/menus.py +++ b/menus.py @@ -1156,9 +1156,10 @@ class PesterOptions(QtGui.QDialog): avail_themes = self.config.availableThemes() self.themeBox = QtGui.QComboBox(self) + notheme = (theme.name not in avail_themes) for (i, t) in enumerate(avail_themes): self.themeBox.addItem(t) - if t == theme.name: + if (not notheme and t == theme.name) or (notheme and t == "pesterchum"): self.themeBox.setCurrentIndex(i) self.buttonOptions = ["Minimize to Taskbar", "Minimize to Tray", "Quit"] diff --git a/profile.py b/profile.py index e40b5e5..14504cf 100644 --- a/profile.py +++ b/profile.py @@ -517,12 +517,17 @@ class pesterTheme(dict): self.path = _datadir+"themes/%s" % (name) if not os.path.exists(self.path): self.path = "themes/%s" % (name) + if not os.path.exists(self.path): + self.path = "themes/pesterchum" self.name = name - fp = open(self.path+"/style.js") - theme = json.load(fp, object_hook=self.pathHook) + try: + fp = open(self.path+"/style.js") + theme = json.load(fp, object_hook=self.pathHook) + fp.close() + except IOError: + theme = json.loads("{}") self.update(theme) - fp.close() if self.has_key("inherits"): self.inheritedTheme = pesterTheme(self["inherits"]) if not default: