Always clean up editor tempfiles, even on exit != 0

This commit is contained in:
Florian Bruhin 2014-05-27 07:43:07 +02:00
parent b29a00dff5
commit 06b0761755

View File

@ -61,18 +61,21 @@ class ExternalEditor(QObject):
editing_finished: If process exited normally. editing_finished: If process exited normally.
""" """
logger.debug("Editor closed") logger.debug("Editor closed")
if exitstatus != QProcess.NormalExit:
# No error/cleanup here, since we already handle this in
# on_proc_error
return
try:
if exitcode != 0: if exitcode != 0:
message.error("Editor did quit abnormally (status {})!".format( message.error("Editor did quit abnormally (status {})!".format(
exitcode)) exitcode))
return return
if exitstatus != QProcess.NormalExit:
# No error here, since we already handle this in on_editor_error
return
with open(self.filename, 'r') as f: with open(self.filename, 'r') as f:
text = ''.join(f.readlines()) text = ''.join(f.readlines())
logger.debug("Read back: {}".format(text)) logger.debug("Read back: {}".format(text))
self._cleanup()
self.editing_finished.emit(text) self.editing_finished.emit(text)
finally:
self._cleanup()
def on_proc_error(self, error): def on_proc_error(self, error):
"""Display an error message and clean up when editor crashed.""" """Display an error message and clean up when editor crashed."""