clean up code/ dont crash if keyboard unplugs

This commit is contained in:
chrys 2017-02-26 14:45:14 +01:00
parent 119a36a6ca
commit 21e7f68235
3 changed files with 13 additions and 30 deletions

View File

@ -11,4 +11,6 @@ generalInformation = {
'tutorialMode': False,
'currUser':'',
'prevUser':'',
'managerList':['inputManager','screenManager','commandManager','outputManager'
,'punctuationManager','cursorManager','applicationManager','debug'],
}

View File

@ -97,35 +97,11 @@ class fenrir():
self.shutdownRequest()
def shutdown(self):
if self.environment['runtime']['inputManager']:
self.environment['runtime']['inputManager'].shutdown()
del self.environment['runtime']['inputManager']
self.environment['runtime']['outputManager'].presentText("Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True)
time.sleep(0.9) # wait a little for sound
if self.environment['runtime']['screenManager']:
self.environment['runtime']['screenManager'].shutdown()
del self.environment['runtime']['screenManager']
if self.environment['runtime']['commandManager']:
self.environment['runtime']['commandManager'].shutdown()
del self.environment['runtime']['commandManager']
if self.environment['runtime']['outputManager']:
self.environment['runtime']['outputManager'].shutdown()
del self.environment['runtime']['outputManager']
if self.environment['runtime']['punctuationManager']:
self.environment['runtime']['punctuationManager'].shutdown()
del self.environment['runtime']['punctuationManager']
if self.environment['runtime']['cursorManager']:
self.environment['runtime']['cursorManager'].shutdown()
del self.environment['runtime']['cursorManager']
if self.environment['runtime']['applicationManager']:
self.environment['runtime']['applicationManager'].shutdown()
del self.environment['runtime']['applicationManager']
if self.environment['runtime']['debug']:
self.environment['runtime']['debug'].shutdown()
del self.environment['runtime']['debug']
time.sleep(0.2) # wait a little before splatter it :)
for currManager in self.environment['generalInformation']['managerList']:
if self.environment['runtime'][currManager]:
self.environment['runtime'][currManager].shutdown()
del self.environment['runtime'][currManager]
self.environment = None
def main():

View File

@ -50,7 +50,12 @@ class driver():
r, w, x = select(self.iDevices, [], [], self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay'))
if r != []:
for fd in r:
try:
event = self.iDevices[fd].read_one()
except:
#print('jow')
del(self.iDevices[fd])
return None
foreward = False
while(event):
self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])