Edit book: Fix regression that caused an error when trying to edit files with no defined syntax, such as plain .txt files. Fixes #1318139 [Editor: Synatax-Highlighter error](https://bugs.launchpad.net/calibre/+bug/1318139)

This commit is contained in:
Kovid Goyal 2014-05-10 15:33:30 +05:30
parent 359e410920
commit 29c8943ebd

View File

@ -107,7 +107,7 @@ class SyntaxHighlighter(object):
@pyqtSlot(int, int, int)
def reformat_blocks(self, position, removed, added):
doc = self.doc
if doc is None:
if doc is None or not hasattr(self, 'state_map'):
return
last_block = doc.findBlock(position + added + (1 if removed > 0 else 0))
if not last_block.isValid():