Handle presence of ascii control characters when saving history for line edits

This commit is contained in:
Kovid Goyal 2017-06-29 09:16:37 +05:30
parent 27e39f6885
commit db3bfa0f5f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -15,7 +15,7 @@ from PyQt5.Qt import (QIcon, QFont, QLabel, QListWidget, QAction,
from calibre.gui2 import (error_dialog, pixmap_to_data, gprefs,
warning_dialog)
from calibre.gui2.filename_pattern_ui import Ui_Form
from calibre import fit_image, strftime
from calibre import fit_image, strftime, force_unicode
from calibre.ebooks import BOOK_EXTENSIONS
from calibre.utils.config import prefs, XMLConfig
from calibre.gui2.progress_indicator import ProgressIndicator as _ProgressIndicator
@ -674,7 +674,15 @@ class HistoryLineEdit(QComboBox): # {{{
self.addItems(items)
self.setEditText(ct)
self.blockSignals(False)
history.set(self.store_name, items)
try:
history.set(self.store_name, items)
except ValueError:
from calibre.utils.cleantext import clean_ascii_chars
items = [clean_ascii_chars(force_unicode(x)) for x in items]
try:
history.set(self.store_name, items)
except ValueError:
pass
def setText(self, t):
self.setEditText(t)