]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blobdiff - music_sampler/mapping.py
Leave application correctly when clicking on the cross button
[perso/Immae/Projets/Python/MusicSampler.git] / music_sampler / mapping.py
index 74feec886f6f37b623b484314ac0012b927abafb..e589ac0a93edfdb234587e25ab6cb1d15a4d7d1b 100644 (file)
@@ -124,22 +124,24 @@ class Mapping(RelativeLayout):
             threading.Thread(name="MSKeyAction", target=key.run,
                     args=['-'.join(modifiers)]).start()
         elif 'ctrl' in modifiers and (keycode[0] == 113 or keycode[0] == '99'):
-            self.keyboard.unbind(on_key_down=self.on_keyboard_down)
-            self.stop_all_running()
-            for music in self.open_files.values():
-                music.stop()
-            for thread in threading.enumerate():
-                if thread.getName()[0:2] == "MS":
-                    thread.join()
-                elif thread.__class__ == threading.Timer:
-                    thread.cancel()
-                    thread.join()
-
+            self.leave_application()
             sys.exit()
         elif 'ctrl' in modifiers and keycode[0] == 114:
             threading.Thread(name="MSReload", target=self.reload).start()
         return True
 
+    def leave_application(self):
+        self.keyboard.unbind(on_key_down=self.on_keyboard_down)
+        self.stop_all_running()
+        for music in self.open_files.values():
+            music.stop()
+        for thread in threading.enumerate():
+            if thread.getName()[0:2] == "MS":
+                thread.join()
+            elif thread.__class__ == threading.Timer:
+                thread.cancel()
+                thread.join()
+
     # Helpers
     def allowed_modifiers(self, modifiers):
         allowed = []