kmonsoor / pyglet

Automatically exported from code.google.com/p/pyglet
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

FIX: Prevent user mouse stupidity #739

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I run a complex program that relies on Pyglet. Sometimes I hit a use case where 
I need to gracefully exit, and it's possible the window will be closed before a 
cleanup function tries to show the mouse cursor again, i.e. it will essentially 
do:

import pyglet
window = pyglet.window.Window(visible=False)
window.close()
window.set_mouse_visible(True)

This throws the following error:

Traceback (most recent call last):
  File "/home/larsoner/Desktop/untitled2.py", line 11, in <module>
    window.set_mouse_visible(True)
  File "/home/larsoner/custombuilds/pyglet/pyglet/window/__init__.py", line 1043, in set_mouse_visible
    self.set_mouse_platform_visible()
  File "/home/larsoner/custombuilds/pyglet/pyglet/window/xlib/__init__.py", line 620, in set_mouse_platform_visible
    xlib.XUndefineCursor(self._x_display, self._window)
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: wrong type

`Xlib` handler can be easily changed to deal with this corner case by editing 
`pyglet/window/xlib/__init__.py` to add these two lines to the top of 
`set_mouse_platform_visible`:

        if not self._window:
            return

Let me know what you think.

Original issue reported on code.google.com by larson.e...@gmail.com on 24 Apr 2014 at 12:55

GoogleCodeExporter commented 9 years ago

Original comment by useboxnet on 24 Apr 2014 at 5:32

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 3905eaea74d1.

Original comment by useboxnet on 8 May 2014 at 6:04

GoogleCodeExporter commented 9 years ago
I had to revert the change, it doesn't work in Windows.

Original comment by useboxnet on 17 May 2014 at 9:13

GoogleCodeExporter commented 9 years ago
This issue was closed by revision dfee8be9740e.

Original comment by useboxnet on 19 May 2014 at 4:16