aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-09-19 19:58:54 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-09-19 19:58:54 +0200
commitf9aeecf1a00e0e632546db00cb0cfa31b078dbe9 (patch)
treec7dc2e8b589c87d50961b60ddfa17b739ef4e9fb
parent269c6bdaba62b79bb832d3e1cc516fff013a7dc3 (diff)
downloadMusicSampler-f9aeecf1a00e0e632546db00cb0cfa31b078dbe9.tar.gz
MusicSampler-f9aeecf1a00e0e632546db00cb0cfa31b078dbe9.tar.zst
MusicSampler-f9aeecf1a00e0e632546db00cb0cfa31b078dbe9.zip
Don't lock the application when failing while reloading configuration
-rw-r--r--music_sampler/mapping.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py
index 5c61f8a..a526ad2 100644
--- a/music_sampler/mapping.py
+++ b/music_sampler/mapping.py
@@ -72,9 +72,9 @@ class Mapping(RelativeLayout):
72 self.keyboard = Window.request_keyboard(self.on_keyboard_closed, self) 72 self.keyboard = Window.request_keyboard(self.on_keyboard_closed, self)
73 self.keyboard.bind(on_key_down=self.on_keyboard_down) 73 self.keyboard.bind(on_key_down=self.on_keyboard_down)
74 74
75 self.configure() 75 self.configure(initial=True)
76 76
77 def on_enter_configuring(self): 77 def on_enter_configuring(self, initial=True):
78 if Config.builtin_mixing: 78 if Config.builtin_mixing:
79 self.mixer = Mixer() 79 self.mixer = Mixer()
80 else: 80 else:
@@ -84,9 +84,9 @@ class Mapping(RelativeLayout):
84 self.key_config, self.open_files = self.parse_config() 84 self.key_config, self.open_files = self.parse_config()
85 except Exception as e: 85 except Exception as e:
86 error_print("Error while loading configuration: {}".format(e), 86 error_print("Error while loading configuration: {}".format(e),
87 with_trace=True, exit=True) 87 with_trace=False, exit=initial)
88 else: 88
89 self.success() 89 self.success()
90 90
91 def on_enter_loading(self): 91 def on_enter_loading(self):
92 for key in self.keys: 92 for key in self.keys:
@@ -118,7 +118,7 @@ class Mapping(RelativeLayout):
118 self.leave_application() 118 self.leave_application()
119 sys.exit() 119 sys.exit()
120 elif 'ctrl' in modifiers and keycode[0] == 114 and self.is_loaded(): 120 elif 'ctrl' in modifiers and keycode[0] == 114 and self.is_loaded():
121 self.reload() 121 self.reload(initial=False)
122 return True 122 return True
123 123
124 def leave_application(self): 124 def leave_application(self):
@@ -348,13 +348,11 @@ class Mapping(RelativeLayout):
348 try: 348 try:
349 config = yaml.safe_load(stream) 349 config = yaml.safe_load(stream)
350 except Exception as e: 350 except Exception as e:
351 error_print("Error while loading config file: {}".format(e), 351 raise Exception("Error while loading config file: {}".format(e)) from e
352 exit=True)
353 stream.close() 352 stream.close()
354 353
355 if not isinstance(config, dict): 354 if not isinstance(config, dict):
356 error_print("Top level config is supposed to be a hash", 355 raise Exception("Top level config is supposed to be a hash")
357 exit=True)
358 356
359 if 'aliases' in config and isinstance(config['aliases'], dict): 357 if 'aliases' in config and isinstance(config['aliases'], dict):
360 aliases = config['aliases'] 358 aliases = config['aliases']