[Pyobjc-dev] Crash when closing all documents
Brought to you by:
ronaldoussoren
From: Daniel M. <mil...@gm...> - 2009-11-19 00:48:38
|
I'm having problems calling the selector provided by NSDocumentController .closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo: Here's my code: class DocumentController(NSDocumentController): ... def closeAllDocumentsWithDelegate_didCloseAllSelector_contextInfo_( self, delegate, selector, context): def callback(result): log.debug("%s.%s(%s, %s, %s)", delegate, selector, self, result, context) perform_selector(delegate, selector, self, result, context) saver = DocumentSavingDelegate.alloc().\ initWithDocuments_callback_context_( self.controller.iter_dirty_documents(), callback, context) saver.save_next_document() def perform_selector(delegate, selector, *args): # sel = selector.replace(":", "_") # HACK # getattr(delegate, sel)(*args) inv = NSInvocation.invocationWithMethodSignature_( delegate.methodSignatureForSelector_(selector)) inv.setTarget_(delegate) inv.setSelector_(selector) for i, arg in enumerate(args): inv.setArgument_atIndex_(arg, i + 2) inv.invoke() Here's the debug message and stack trace I get when the callback gets called: DEBUG <DocumentController: 0x114ab0>._documentController:shouldTerminate:context: (<DocumentController: 0x114ab0>, True, 1401200) 2009-11-18 19:32:36.137 EditXTDev[51404:60b] *** ObjC exception 'NSUncaughtSystemExceptionException' (reason: 'Uncaught system exception: signal 10') discarded Stack trace (most recent call last): -[NSMenu _performActionWithHighlightingForItemAtIndex:] (in AppKit) + 49 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] (in AppKit) + 174 -[NSMenuItem _corePerformAction] (in AppKit) + 435 -[NSApplication sendAction:to:from:] (in AppKit) + 112 -[NSApplication terminate:] (in AppKit) + 519 -[NSApplication _shouldTerminate] (in AppKit) + 669 -[NSApplication sendEvent:] (in AppKit) + 6431 -[NSWindow sendEvent:] (in AppKit) + 5549 -[NSControl mouseDown:] (in AppKit) + 812 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] (in AppKit) + 524 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] (in AppKit) + 1808 -[NSCell _sendActionFrom:] (in AppKit) + 169 -[NSControl sendAction:to:] (in AppKit) + 108 -[NSApplication sendAction:to:from:] (in AppKit) + 112 -[NSAlert buttonPressed:] (in AppKit) + 392 -[NSApplication endSheet:returnCode:] (in AppKit) + 349 -[NSAlert didEndSheet:returnCode:contextInfo:] (in AppKit) + 133 -[NSWindow orderOut:] (in AppKit) + 50 -[NSWindow orderWindow:relativeTo:] (in AppKit) + 105 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] (in AppKit) + 1836 -[NSWindow(NSSheets) _orderOutRelativeToWindow:] (in AppKit) + 123 -[NSMoveHelper(NSSheets) _closeSheet:andMoveParent:] (in AppKit) + 463 -[NSWindow(NSSheets) _detachSheetWindow] (in AppKit) + 501 -[NSNotificationCenter postNotificationName:object:] (in Foundation) + 56 -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation) + 128 _CFXNotificationPostNotification (in CoreFoundation) + 186 __CFXNotificationPost (in CoreFoundation) + 905 _nsnote_callback (in Foundation) + 176 ffi_closure_SYSV (in _objc.so) + 196 method_stub (in _objc.so) + 1687 PyObject_Call (in libpython2.6.dylib) (abstract.c:2492) function_call (in libpython2.6.dylib) (funcobject.c:524) PyEval_EvalCodeEx (in libpython2.6.dylib) (ceval.c:2968) PyEval_EvalFrameEx (in libpython2.6.dylib) (ceval.c:3917) PyObject_Call (in libpython2.6.dylib) (abstract.c:2492) pysel_call (in _objc.so) + 1264 PyObject_Call (in libpython2.6.dylib) (abstract.c:2492) function_call (in libpython2.6.dylib) (funcobject.c:524) PyEval_EvalCodeEx (in libpython2.6.dylib) (ceval.c:2968) PyEval_EvalFrameEx (in libpython2.6.dylib) (ceval.c:3917) PyObject_Call (in libpython2.6.dylib) (abstract.c:2492) pysel_call (in _objc.so) + 1264 PyObject_Call (in libpython2.6.dylib) (abstract.c:2492) function_call (in libpython2.6.dylib) (funcobject.c:524) PyEval_EvalCodeEx (in libpython2.6.dylib) (ceval.c:2968) PyEval_EvalFrameEx (in libpython2.6.dylib) (ceval.c:3802) PyEval_EvalCodeEx (in libpython2.6.dylib) (ceval.c:2968) PyEval_EvalFrameEx (in libpython2.6.dylib) (ceval.c:3802) PyEval_EvalCodeEx (in libpython2.6.dylib) (ceval.c:2968) PyEval_EvalFrameEx (in libpython2.6.dylib) (ceval.c:3917) PyObject_Call (in libpython2.6.dylib) (abstract.c:2492) objcsel_call (in _objc.so) + 230 PyObjCFFI_Caller (in _objc.so) + 2709 ffi_call (in _objc.so) + 147 .LCFI1 (in _objc.so) (x86-darwin.S:84) -[NSInvocation invoke] (in CoreFoundation) + 136 __invoking___ (in CoreFoundation) + 29 -[NSDocumentController(NSInternal) _documentController:shouldTerminate:context:] (in AppKit) + 321 0xffffffff _sigtramp (in libSystem.B.dylib) + 43 NSExceptionHandlerUncaughtSignalHandler (in ExceptionHandling) + 65 Am I doing something wrong or is this a bug? Versions: Mac OS X 10.6 Python 2.6.2 PyObjC 2.2b2 Thanks in advance for any help you can provide. ~ Daniel |