Bug fix: Don't break when using non-existant theme

This commit is contained in:
Kiooeht 2011-09-12 21:15:35 -07:00
parent dc2eaf7ce8
commit 75532fb2ff
4 changed files with 11 additions and 5 deletions

View file

@ -39,6 +39,7 @@ CHANGELOG
* Alt characters don't break on random replace - Kiooeht [evacipatedBox] * Alt characters don't break on random replace - Kiooeht [evacipatedBox]
* Trollian 2.5 tray icon is now Trollian icon - Kiooeht [evacipatedBox] * Trollian 2.5 tray icon is now Trollian icon - Kiooeht [evacipatedBox]
* Don't screw up <c> tags with the mispeller - Kiooeht [evacipatedBox] * Don't screw up <c> tags with the mispeller - Kiooeht [evacipatedBox]
* Don't break if profile uses non-existant theme - Kiooeht [evacipatedBox]
* Mac Bug fixes * Mac Bug fixes
* Create all datadir stuff - Lexi [lexicalNuance] * Create all datadir stuff - Lexi [lexicalNuance]

View file

@ -33,7 +33,6 @@ Bugs
* Closing a timeclone doesn't actually cease for everyone else * Closing a timeclone doesn't actually cease for everyone else
* Kill Zalgo * Kill Zalgo
* Random invisible, tiny links to last link at end of every message * Random invisible, tiny links to last link at end of every message
* Profiles using themes you don't have break everything
Windows Bugs Windows Bugs
------------ ------------

View file

@ -1156,9 +1156,10 @@ class PesterOptions(QtGui.QDialog):
avail_themes = self.config.availableThemes() avail_themes = self.config.availableThemes()
self.themeBox = QtGui.QComboBox(self) self.themeBox = QtGui.QComboBox(self)
notheme = (theme.name not in avail_themes)
for (i, t) in enumerate(avail_themes): for (i, t) in enumerate(avail_themes):
self.themeBox.addItem(t) 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.themeBox.setCurrentIndex(i)
self.buttonOptions = ["Minimize to Taskbar", "Minimize to Tray", "Quit"] self.buttonOptions = ["Minimize to Taskbar", "Minimize to Tray", "Quit"]

View file

@ -517,12 +517,17 @@ class pesterTheme(dict):
self.path = _datadir+"themes/%s" % (name) self.path = _datadir+"themes/%s" % (name)
if not os.path.exists(self.path): if not os.path.exists(self.path):
self.path = "themes/%s" % (name) self.path = "themes/%s" % (name)
if not os.path.exists(self.path):
self.path = "themes/pesterchum"
self.name = name self.name = name
fp = open(self.path+"/style.js") try:
theme = json.load(fp, object_hook=self.pathHook) fp = open(self.path+"/style.js")
theme = json.load(fp, object_hook=self.pathHook)
fp.close()
except IOError:
theme = json.loads("{}")
self.update(theme) self.update(theme)
fp.close()
if self.has_key("inherits"): if self.has_key("inherits"):
self.inheritedTheme = pesterTheme(self["inherits"]) self.inheritedTheme = pesterTheme(self["inherits"])
if not default: if not default: