From 95387af2cdc0af6995bef25171e6a3b285ce7808 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sun, 14 Jul 2019 11:19:29 +1000 Subject: [PATCH] cleanup recording on cancel --- anki/sound.py | 7 +++++-- aqt/sound.py | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/anki/sound.py b/anki/sound.py index d41ea8f8e..aa3431b14 100644 --- a/anki/sound.py +++ b/anki/sound.py @@ -334,13 +334,16 @@ class _Recorder: except: ret = True finally: - if os.path.exists(processingSrc): - os.unlink(processingSrc) + self.cleanup() if ret: raise Exception(_( "Error running %s") % " ".join(cmd)) + def cleanup(self): + if os.path.exists(processingSrc): + os.unlink(processingSrc) + class PyAudioThreadedRecorder(threading.Thread): def __init__(self, startupDelay): diff --git a/aqt/sound.py b/aqt/sound.py index 2ca97be6e..0bcf70cc6 100644 --- a/aqt/sound.py +++ b/aqt/sound.py @@ -40,6 +40,7 @@ def getAudio(parent, encode=True): QApplication.instance().processEvents() if mb.clickedButton() == mb.escapeButton(): r.stop() + r.cleanup() return saveGeom(mb, "audioRecorder") # ensure at least a second captured