From 7698d36f84e12dcca1b549cb469ce8cb803333e7 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 6 Apr 2010 19:15:30 +0900 Subject: [PATCH] catch media adding errors --- ankiqt/ui/facteditor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py index a245cda99..786dfdc54 100644 --- a/ankiqt/ui/facteditor.py +++ b/ankiqt/ui/facteditor.py @@ -894,10 +894,17 @@ class FactEditor(object): w = widget else: w = self.focusedEdit() - path = self.deck.addMedia(file) + path = self._addMedia(file) self.maybeDelete(path, file) w.insertHtml('' % path) + def _addMedia(self, file): + try: + self.deck.addMedia(file) + except (IOError, OSError), e: + ui.utils.showWarning(_("Unable to add media: %s") % unicode(e), + parent=self.parent) + def onAddSound(self): # get this before we open the dialog w = self.focusedEdit() @@ -915,7 +922,7 @@ class FactEditor(object): w = widget else: w = self.focusedEdit() - path = self.deck.addMedia(file) + path = self._addMedia(file) self.maybeDelete(path, file) anki.sound.play(path) w.insertHtml('[sound:%s]' % path)