> Trying to figure why the following test app crashes when a 'testtest' > Apple event is sent to it: > > ------------------------------------------------------------ > # cocoatest.py > > from PyObjCTools import AppHelper > from Carbon.AE import AEInstallEventHandler > > AEInstallEventHandler('test', 'test', lambda evt, res:0) > > AppHelper.runEventLoop() > > ------------------------------------------------------------ > > Additional notes: the test app doesn't crash when > AppKit.NSAppleEventManager is used to install the event handler function, > nor when CarbonEvt is used instead of PyObjC. > > I'm getting a similar crash in some CarbonX.OSA code within a PyObjC-based > app and reckon identifying what's causing the test app to crash will help > me solve the problem there. Any ideas as to the cause, suggestions where > to look, how to debug it more effectively, etc. would be a big help as > I've been stuck on this for more than a day now and have only just fitted > a new laptop case after the last temper tantrum. :p
My guess is that there's a refcount or GIL bug in Carbon.AE.AEInstallEventHandler. I'd use NSAppleEventManager... I've used it before and it works just fine. def initializeAsynchronousAppleEvents(self): aem = NSAppleEventManager.sharedAppleEventManager() aem.setEventHandler_andSelector_forEventClass_andEventID_( self, 'handleAppleEvent:withReplyEvent:', struct.unpack('>i', 'aevt')[0], struct.unpack('>i', 'ansr')[0]) def handleAppleEvent_withReplyEvent_(self, event, replyEvent): reply = event.aeDesc() ... -bob _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig