Fix unicode handling when editing tweaks

This commit is contained in:
Kovid Goyal 2010-08-12 10:57:47 -06:00
parent 05acab2c34
commit 6eade64d80

View File

@ -515,15 +515,15 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
self.reset_confirmation_button.clicked.connect(self.reset_confirmation) self.reset_confirmation_button.clicked.connect(self.reset_confirmation)
deft, curt = read_raw_tweaks() deft, curt = read_raw_tweaks()
self.current_tweaks.setPlainText(curt) self.current_tweaks.setPlainText(curt.decode('utf-8'))
self.default_tweaks.setPlainText(deft) self.default_tweaks.setPlainText(deft.decode('utf-8'))
self.restore_tweaks_to_default_button.clicked.connect(self.restore_tweaks_to_default) self.restore_tweaks_to_default_button.clicked.connect(self.restore_tweaks_to_default)
self.category_view.setCurrentIndex(self.category_view.model().index_for_name(initial_category)) self.category_view.setCurrentIndex(self.category_view.model().index_for_name(initial_category))
def restore_tweaks_to_default(self, *args): def restore_tweaks_to_default(self, *args):
deft, curt = read_raw_tweaks() deft, curt = read_raw_tweaks()
self.current_tweaks.setPlainText(deft) self.current_tweaks.setPlainText(deft.decode('utf-8'))
def reset_confirmation(self): def reset_confirmation(self):
@ -698,8 +698,7 @@ class ConfigDialog(ResizableDialog, Ui_Dialog):
self.input_order.setCurrentRow(idx-1) self.input_order.setCurrentRow(idx-1)
def set_tweaks(self): def set_tweaks(self):
raw = unicode(self.current_tweaks.toPlainText()) raw = unicode(self.current_tweaks.toPlainText()).encode('utf-8')
raw = re.sub(r'(?m)^#.*fileencoding.*', '# ', raw)
try: try:
exec raw exec raw
except: except: