You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is bug in set_handler. E.g. pyglet crash with simple code below:
import pyglet
window = pyglet.window.Window()
def on_draw():
pass
window.push_handlers(on_draw)
window.pop_handlers()
@window.event
def on_resize(w, h):
pass
pyglet.app.run()
The reason is that in pop_handlers del self._event_stack[0] is used to delete
events on top of stack and in set_handler inserting events is doing by
self._event_stack[0][name] = handler without checking the length of
event_stack. Fix is as simple as adding check, but personally I think it would
be better to rewrite whole stack code.
First of all I don't understand why empty stack is defined as tuple and changed
to list if event are to be added. It only complicates the code.
Pushing new element on stack in done by
self._event_stack.insert(0, {})
self.set_handlers(*args, **kwargs)
while I think using append list method would be better (and probably faster)
pop_handlers:
now: del self._event_stack[0]
new: self._event_stack.pop()
I hope you get general idea. If you agree with above suggestions I can refactor
code and provide patch.
Original issue reported on code.google.com by fen...@gmail.com on 7 Sep 2014 at 7:58
The text was updated successfully, but these errors were encountered:
Original issue reported on code.google.com by
fen...@gmail.com
on 7 Sep 2014 at 7:58The text was updated successfully, but these errors were encountered: