Skip to content

Commit

Permalink
ToC Editor: Fix save/load of settings int he XPath wizard not working…
Browse files Browse the repository at this point in the history
… across restarts
  • Loading branch information
kovidgoyal committed May 26, 2015
1 parent 9daaa81 commit 9bf8dcf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/calibre/gui2/toc/main.py
Expand Up @@ -75,7 +75,8 @@ def save_settings(self):
name = unicode(name).strip()
if name:
saved = self.prefs.get('xpath_toc_settings', {})
saved[name] = {i:x for i, x in enumerate(xpaths)}
# in JSON all keys have to be strings
saved[name] = {str(i):x for i, x in enumerate(xpaths)}
self.prefs.set('xpath_toc_settings', saved)
self.setup_load_button()

Expand All @@ -98,7 +99,7 @@ def clear_settings(self):
def load_settings(self, name):
saved = self.prefs.get('xpath_toc_settings', {}).get(name, {})
for i, w in enumerate(self.widgets):
txt = saved.get(i, '')
txt = saved.get(str(i), '')
w.edit.setText(txt)

def check(self):
Expand Down

0 comments on commit 9bf8dcf

Please sign in to comment.