]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Don't lock the application when failing while reloading configuration heads/load_action
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 19 Sep 2016 17:58:54 +0000 (19:58 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 19 Sep 2016 17:58:54 +0000 (19:58 +0200)
music_sampler/mapping.py

index 5c61f8a5be6eb318949400bfb80398e3cd03472a..a526ad2244485174fb03a97a1a3491dc5d184cd3 100644 (file)
@@ -72,9 +72,9 @@ class Mapping(RelativeLayout):
         self.keyboard = Window.request_keyboard(self.on_keyboard_closed, self)
         self.keyboard.bind(on_key_down=self.on_keyboard_down)
 
-        self.configure()
+        self.configure(initial=True)
 
-    def on_enter_configuring(self):
+    def on_enter_configuring(self, initial=True):
         if Config.builtin_mixing:
             self.mixer = Mixer()
         else:
@@ -84,9 +84,9 @@ class Mapping(RelativeLayout):
             self.key_config, self.open_files = self.parse_config()
         except Exception as e:
             error_print("Error while loading configuration: {}".format(e),
-                    with_trace=True, exit=True)
-        else:
-            self.success()
+                    with_trace=False, exit=initial)
+
+        self.success()
 
     def on_enter_loading(self):
         for key in self.keys:
@@ -118,7 +118,7 @@ class Mapping(RelativeLayout):
             self.leave_application()
             sys.exit()
         elif 'ctrl' in modifiers and keycode[0] == 114 and self.is_loaded():
-            self.reload()
+            self.reload(initial=False)
         return True
 
     def leave_application(self):
@@ -348,13 +348,11 @@ class Mapping(RelativeLayout):
         try:
             config = yaml.safe_load(stream)
         except Exception as e:
-            error_print("Error while loading config file: {}".format(e),
-                    exit=True)
+            raise Exception("Error while loading config file: {}".format(e)) from e
         stream.close()
 
         if not isinstance(config, dict):
-            error_print("Top level config is supposed to be a hash",
-                    exit=True)
+            raise Exception("Top level config is supposed to be a hash")
 
         if 'aliases' in config and isinstance(config['aliases'], dict):
             aliases = config['aliases']