'Write the editor text into the form field and clean up tempfile.
Callback for QProcess when the editor was closed.'

@pyqtSlot(int, QProcess.ExitStatus)
def on_proc_closed(self, exitcode, exitstatus):

    log.procs.debug('Editor    closed')
    if (exitstatus != QProcess.NormalExit):
        return
    try:
        if (exitcode != 0):
            return
        encoding = config.get('general', 'editor-encoding')
        try:
            with open(self._file.name, 'r', encoding=encoding) as f:
                text = f.read()
        except OSError as e:
            message.error('Failed    to    read    back    edited    file:    {}'.format(e))
            return
        log.procs.debug('Read    back:    {}'.format(text))
        self.editing_finished.emit(text)
    finally:
        self._cleanup()
