From a49f93078f02c611090132ce9cab6edca31a3f9b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 29 Jul 2016 03:22:33 +0200 Subject: [PATCH] Cancel all timers and stop all musics when exiting --- music_sampler/mapping.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/music_sampler/mapping.py b/music_sampler/mapping.py index 0d58d30..74feec8 100644 --- a/music_sampler/mapping.py +++ b/music_sampler/mapping.py @@ -124,11 +124,16 @@ 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": - continue - thread.join() + if thread.getName()[0:2] == "MS": + thread.join() + elif thread.__class__ == threading.Timer: + thread.cancel() + thread.join() sys.exit() elif 'ctrl' in modifiers and keycode[0] == 114: -- 2.41.0