From: Ismaƫl Bouya Date: Fri, 29 Jul 2016 01:22:33 +0000 (+0200) Subject: Cancel all timers and stop all musics when exiting X-Git-Tag: 1.0.2 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git;a=commitdiff_plain;h=a49f93078f02c611090132ce9cab6edca31a3f9b Cancel all timers and stop all musics when exiting --- 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: