mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 06:07:11 -05:00
catch media adding errors
This commit is contained in:
parent
4928c21914
commit
7698d36f84
1 changed files with 9 additions and 2 deletions
|
|
@ -894,10 +894,17 @@ class FactEditor(object):
|
||||||
w = widget
|
w = widget
|
||||||
else:
|
else:
|
||||||
w = self.focusedEdit()
|
w = self.focusedEdit()
|
||||||
path = self.deck.addMedia(file)
|
path = self._addMedia(file)
|
||||||
self.maybeDelete(path, file)
|
self.maybeDelete(path, file)
|
||||||
w.insertHtml('<img src="%s">' % path)
|
w.insertHtml('<img src="%s">' % 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):
|
def onAddSound(self):
|
||||||
# get this before we open the dialog
|
# get this before we open the dialog
|
||||||
w = self.focusedEdit()
|
w = self.focusedEdit()
|
||||||
|
|
@ -915,7 +922,7 @@ class FactEditor(object):
|
||||||
w = widget
|
w = widget
|
||||||
else:
|
else:
|
||||||
w = self.focusedEdit()
|
w = self.focusedEdit()
|
||||||
path = self.deck.addMedia(file)
|
path = self._addMedia(file)
|
||||||
self.maybeDelete(path, file)
|
self.maybeDelete(path, file)
|
||||||
anki.sound.play(path)
|
anki.sound.play(path)
|
||||||
w.insertHtml('[sound:%s]' % path)
|
w.insertHtml('[sound:%s]' % path)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue