sightmachine / SimpleCV

The Open Source Framework for Machine Vision
http://simplecv.org
BSD 3-Clause "New" or "Revised" License
2.68k stars 798 forks source link

Display.checkEvents(): don't keep processing events on QUIT #657

Closed keunwoo closed 6 years ago

keunwoo commented 9 years ago

On my test setup, continuing to process events when the QUIT event is received results in the following output on stderr:

ERROR:
Traceback (most recent call last):
  File "/Users/keunwoo/Documents/cvplay/ENV/lib/python2.7/site-packages/SimpleCV/examples/detection/barcode_reader.py", line 29, in <module>
    while display.isNotDone():
  File "/Users/keunwoo/Documents/cvplay/ENV/lib/python2.7/site-packages/SimpleCV/Display.py", line 689, in isNotDone
    return not self.isDone()
  File "/Users/keunwoo/Documents/cvplay/ENV/lib/python2.7/site-packages/SimpleCV/Display.py", line 667, in isDone
    self.checkEvents()
  File "/Users/keunwoo/Documents/cvplay/ENV/lib/python2.7/site-packages/SimpleCV/Display.py", line 630, in checkEvents
    self.pressed = pg.key.get_pressed()
error: video system not initialized
Cleaned up camera.

The error message appears to be benign, but it would be cleaner not to print it; at a minimum, it is confusing/alarming for new users.

This commit is based on the answer here:

http://help.simplecv.org/question/1505/error-with-example-from-page-25/

I literally just unpacked and ran simplecv for the first time a few minutes ago, so I don't know if this is a correct fix, but it does get rid of the error message. (Naively, it seems like you shouldn't be processing additional events after quit, but I'm not familiar with the pygame framework.)

If accepted, this fix should probably also be backported to the develop branch.

keunwoo commented 6 years ago

nobody cares about this; abandoning