Edit Book: Fix saving of empty files not working

This commit is contained in:
Kovid Goyal 2014-03-17 10:20:16 +05:30
parent 5c2dec8022
commit 77e79d75cb

View File

@ -81,8 +81,11 @@ class PlainTextEdit(QPlainTextEdit):
if hasattr(ans, 'rstrip'): if hasattr(ans, 'rstrip'):
ans = ans.rstrip('\0') ans = ans.rstrip('\0')
else: # QString else: # QString
while ans[-1] == '\0': try:
ans.chop(1) while ans[-1] == '\0':
ans.chop(1)
except IndexError:
pass # ans is an empty string
return ans return ans
@pyqtSlot() @pyqtSlot()