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 exitcode != 0:
message.error("Editor did quit abnormally (status {})!".format(
exitcode))
return
if exitstatus != QProcess.NormalExit: if exitstatus != QProcess.NormalExit:
# No error here, since we already handle this in on_editor_error # No error/cleanup here, since we already handle this in
# on_proc_error
return return
with open(self.filename, 'r') as f: try:
text = ''.join(f.readlines()) if exitcode != 0:
logger.debug("Read back: {}".format(text)) message.error("Editor did quit abnormally (status {})!".format(
self._cleanup() exitcode))
self.editing_finished.emit(text) return
with open(self.filename, 'r') as f:
text = ''.join(f.readlines())
logger.debug("Read back: {}".format(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."""