From: pin Date: Mon, 4 Mar 2013 10:23:54 +0000 (+0000) Subject: Gestion explicite de KeyboardInterrupt pour être sûr de quitter le jeu sur un ^C. X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/commitdiff_plain/975ed3f44e237886978f0063f2907baa8eaf46c1?hp=5fd262589f4c98f0f37c7b9806c12446fd1f8e92 Gestion explicite de KeyboardInterrupt pour être sûr de quitter le jeu sur un ^C. git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@420 fe552daf-6dbe-4428-90eb-1537e0879342 --- diff --git a/src/minwii/widgets/instrumentselector.py b/src/minwii/widgets/instrumentselector.py index 52799d0..f8a5e32 100755 --- a/src/minwii/widgets/instrumentselector.py +++ b/src/minwii/widgets/instrumentselector.py @@ -60,10 +60,14 @@ class InstrumentSelector(pygame.sprite.LayeredDirty, EventHandlerMixin) : pygame.display.flip() pygame.mouse.set_visible(False) while self._running : - EventDispatcher.dispatchEvents() - dirty = self.draw(pygame.display.get_surface()) - pygame.display.update(dirty) - clock.tick(FRAMERATE) + try : + EventDispatcher.dispatchEvents() + dirty = self.draw(pygame.display.get_surface()) + pygame.display.update(dirty) + clock.tick(FRAMERATE) + except KeyboardInterrupt : + self.stop() + raise def stop(self) : self._running = False diff --git a/src/minwii/widgets/playingscreen.py b/src/minwii/widgets/playingscreen.py index 66d05a3..90a6d2a 100755 --- a/src/minwii/widgets/playingscreen.py +++ b/src/minwii/widgets/playingscreen.py @@ -98,11 +98,15 @@ class PlayingScreenBase(pygame.sprite.LayeredDirty, EventHandlerMixin) : pygame.display.flip() pygame.mouse.set_visible(False) while self._running : - EventDispatcher.dispatchEvents() - self.kinectRgb.update() - dirty = self.draw(pygame.display.get_surface()) - pygame.display.update(dirty) - clock.tick(FRAMERATE) + try : + EventDispatcher.dispatchEvents() + self.kinectRgb.update() + dirty = self.draw(pygame.display.get_surface()) + pygame.display.update(dirty) + clock.tick(FRAMERATE) + except KeyboardInterrupt : + self.stop() + raise def stop(self) : self._running = False