Commit d37da163 authored by Mathieu Bridon's avatar Mathieu Bridon

Protect against failures to play the error bell

Playing an error sound is a great way to provide feedback to the user
when they make a mistake.

However, it might fail (e.g bug in the sound stack, or due to the
fragility of pycanberra), and it must not crash the engine.
parent 07c6055d
......@@ -365,8 +365,13 @@ class Engine(IBus.Engine):
if not hasattr(self, "canberra"):
self.canberra = pycanberra.Canberra()
self.canberra.play(1, pycanberra.CA_PROP_EVENT_ID, "dialog-error",
pycanberra.CA_PROP_MEDIA_ROLE, "error", None)
try:
self.canberra.play(1, pycanberra.CA_PROP_EVENT_ID, "dialog-error",
pycanberra.CA_PROP_MEDIA_ROLE, "error", None)
except:
# Playing a sound is a nice indication for the user, but if it
# fails, it should never take down the input system
pass
class EngineCangjie(Engine):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment