Gestion explicite de KeyboardInterrupt pour être sûr de quitter le jeu sur un ^C.
authorpin <pin@fe552daf-6dbe-4428-90eb-1537e0879342>
Mon, 4 Mar 2013 10:23:54 +0000 (10:23 +0000)
committerpin <pin@fe552daf-6dbe-4428-90eb-1537e0879342>
Mon, 4 Mar 2013 10:23:54 +0000 (10:23 +0000)
git-svn-id: https://svn.cri.ensmp.fr/svn/minwii/trunk@420 fe552daf-6dbe-4428-90eb-1537e0879342

src/minwii/widgets/instrumentselector.py
src/minwii/widgets/playingscreen.py

index 52799d0..f8a5e32 100755 (executable)
@@ -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
index 66d05a3..90a6d2a 100755 (executable)
@@ -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