Re: [Pyobjc-dev] bus error in CGEventTapCreate... found the problem
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2009-07-14 07:15:30
|
It has taken me way to long to get around to this, but I finally
commited a fix for this (revision 2266 and 2267). I still have to
write a unittest that uses this API, but that can wait.
On 30 Jun, 2009, at 0:38, Ratko Jagodic wrote:
> I am trying to capture some mouse events using CGEventTapCreate and
> I found out that the following causes a bus error every time:
>
> eventMask = (1<<kCGEventMouseMoved)
> eventTap = CGEventTapCreate(kCGSessionEventTap,
> kCGHeadInsertEventTap, 0, eventMask, myCGEventCallback)
>
>
> I've traced it down to two problems, both in Quartz framework in
> _callbacks.m in the function m_CGEventTapCreate:
>
> (1) the function expects 5 inputs and yet it tries to assign 6, last
> one being "info"... which ends up being an uninitialized pointer.
> That seems to cause a bus error further down when it tries to create
> a tuple of "callback" and "info":
> PyObject* real_info = Py_BuildValue("OO",
> callback, info);
> For my purposes, I just changed CGEventTapCreate to accept 6th input
> when parsing arguments ("OOOOOO"), as it does in carbon. Not sure if
> that's the right approach...
Adding an extra "O" was the correct fix here.
>
>
> (2) After fixing that, I encountered the next bus error with the
> line further down in the same function:
> CFRelease(retval);
> I have no idea why this is crashing but I just commented it out for
> now. I am assuming the worst that can happen is a memory leak and
> considering that I call this only once, I didn't think it was a big
> problem.
This should have been "if (result) { CFRelease(result); }".
Ronald
|