PyUserInput
PyUserInput copied to clipboard
Xlib.error.XError on second click wait run
Hello,
I am having an issue where waiting for a mouse click a second time results in an error within Xlib.
Versions
OS: Ubuntu 14.04LTS xlib version: 15rc1 (i have tried numerous versions) pyuserinput version: 1.0
Implementation
class ClickToggle(PyMouseEvent):
def __init__(self):
PyMouseEvent.__init__(self)
def click(self, x, y, button, press):
if press:
self.stop()
Elsewhere in the program I need to wait for a mouse event so I do the following:
C = ClickToggle()
c.run()
This works fine the first time, however, the second time this happens it results in an Xlib.error. Traceback below.
Traceback (most recent call last):
File "window_control.py", line 168, in <module>
controller = KioskWindowControl()
File "window_control.py", line 56, in __init__
self.__idle_loop()
File "window_control.py", line 154, in __idle_loop
self.__primary_ad_loop()
File "window_control.py", line 131, in __primary_ad_loop
self.toggle.run()
File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/pymouse/x11.py", line 130, in run
self.display2.record_enable_context(self.ctx, self.handler)
File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/ext/record.py", line 240, in enable_context
context = context)
File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/ext/record.py", line 217, in __init__
apply(rq.ReplyRequest.__init__, (self, ) + args, keys)
File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/protocol/rq.py", line 1430, in __init__
self.reply()
File "/home/jevo/jevo_window_control/venv/local/lib/python2.7/site-packages/Xlib/protocol/rq.py", line 1450, in reply
raise self._error
Xlib.error.XError: <class 'Xlib.error.XError'>: code = 153, resource_id = 73400320, sequence_number = 10, major_opcode = 146, minor_opcode = 5
Note: I am interacting with Xlib.display in my program.
Let me know if I can provide any additional information.
Kevin
I have traced it down to this line in def run():
https://github.com/SavinaRoja/PyUserInput/blob/master/pymouse/x11.py#L134
self.display2.record_free_context(self.ctx)
Commenting this out gives the expected behavior, not sure why yet.
Do you call run
twice on the same instance? That would indeed lead to a double free.
Normally you'd call start
to run in the background, which you can only do once.
Different instances.
Each time I need to wait for a click a new instance of the class is created.