Mercurial > touhou
comparison pytouhou/ui/window.pyx @ 588:7a82c4b52b16
Prevent a traceback when we call Window.run without a runner set.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 08 Oct 2014 19:20:15 +0200 |
parents | 00f228b57840 |
children | 0768122da817 |
comparison
equal
deleted
inserted
replaced
587:6c9d8a3d853f | 588:7a82c4b52b16 |
---|---|
76 | 76 |
77 | 77 |
78 | 78 |
79 cdef class Window: | 79 cdef class Window: |
80 def __init__(self, backend, long fps_limit=-1): | 80 def __init__(self, backend, long fps_limit=-1): |
81 self.runner = None | |
82 | |
83 if backend is not None: | 81 if backend is not None: |
84 self.win = backend.create_window( | 82 self.win = backend.create_window( |
85 'PyTouhou', | 83 'PyTouhou', |
86 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, | 84 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, |
87 640, 480) #XXX | 85 640, 480) #XXX |
102 cpdef run(self): | 100 cpdef run(self): |
103 try: | 101 try: |
104 while self.run_frame(): | 102 while self.run_frame(): |
105 pass | 103 pass |
106 finally: | 104 finally: |
107 self.runner.finish() | 105 if self.runner is not None: |
106 self.runner.finish() | |
108 | 107 |
109 | 108 |
110 cdef bint run_frame(self) except? False: | 109 cdef bint run_frame(self) except? False: |
111 cdef bint running = False | 110 cdef bint running = False |
112 if self.runner is not None: | 111 if self.runner is not None: |