Skip to content

Commit

Permalink
If NVDA is unable to communicate with a braille display (e.g. because…
Browse files Browse the repository at this point in the history
… it has been disconnected), it will automatically disable use of the display.

This eliminates problems such as excessive log file size and lag when this occurs.
  • Loading branch information
jcsteh committed Dec 23, 2013
1 parent 930f3e8 commit 34d2efc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/braille.py
Expand Up @@ -1308,7 +1308,11 @@ def _displayWithCursor(self):
cells = list(self._cells)
if self._cursorPos is not None and self._cursorBlinkUp:
cells[self._cursorPos] |= self.cursorShape
self.display.display(cells)

try:
self.display.display(cells)
except:
self.handleDisplayUnavailable()

def _blink(self):
self._cursorBlinkUp = not self._cursorBlinkUp
Expand Down Expand Up @@ -1474,6 +1478,15 @@ def handleConfigProfileSwitch(self):
if display != self.display.name:
self.setDisplayByName(display)

def handleDisplayUnavailable(self):
"""Called when the braille display becomes unavailable.
This logs an error and disables the display.
This is called when displaying cells raises an exception,
but drivers can also call it themselves if appropriate.
"""
log.error("Braille display unavailable. Disabling", exc_info=True)
self.setDisplayByName("noBraille", isFallback=True)

def initialize():
global handler
config.addConfigDirsToPythonPackagePath(brailleDisplayDrivers)
Expand Down

0 comments on commit 34d2efc

Please sign in to comment.