From: Laurent S. <lsa...@ap...> - 2007-08-29 15:22:30
|
Hi Hans, Actually the problem here is that you return a pure Ruby object as the node name to NSOutlineView. When you pass pure Ruby objects to the ObjC world, RubyCocoa will build an ObjC proxy for you. However, the proxy object is built as autoreleased, so that it will be soonly collected if not retained. NSOutlineView expects you to always pass the same objects (in the ObjC world, the same pointer address) as data source items. However, since NSOutlineView doesn't retain the items, the RubyCocoa proxies will be remade, and then NSOutlineView crashes. There is unfortunately no reliable way for RubyCocoa to keep the proxy objects and release them once the embedded Ruby object dies (I tried several code paths unsuccessfully). Fortunately, except for NSOutlineView, the current mechanism seems to always work. To work around this problem, you always have to return NSObject-based objects as NSOutlineView data source items. In your project, I changed Node#setItemName: def setItemName(name) @itemName = NSString.stringWithString(name) end and also #init to call setItemName('node') And I was able to edit cells. We should definitely write this in a Wiki page. Laurent On Aug 29, 2007, at 4:40 PM, Hans-Georg wrote: > RubyCocoa crashes if I a cell in a NSOutlineView is edited. To verify > this download the following file from rubycocoa.com: > > http://rubycocoa.com/files/outline-views/OutlineMeRuby.zip > > Run the project, double-click "Root" In the NSOutlineView and edit > the cell content. If you then click outside the cell, the app will > crash. > > Hans-Georg > > > Exception: EXC_BAD_ACCESS (0x0001) > Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000000 > > Thread 0 Crashed: > 0 libobjc.A.dylib 0x90a40100 objc_msgSend + 32 > 1 com.apple.rubycocoa 0x0002f26c rbobj_to_nsobj + 1436 > 2 com.apple.rubycocoa 0x0002f5f8 rbobj_to_ocdata + 776 > 3 com.apple.rubycocoa 0x00030ea8 sel_to_rbobj + 1544 > 4 com.apple.rubycocoa 0x00042064 > ffi_closure_helper_DARWIN + 644 > 5 com.apple.rubycocoa 0x00042354 ffi_closure_ASM + 116 > 6 com.apple.AppKit 0x93850dd0 -[NSTableView > _drawContentsAtRow:column:clipRect:] + 252 > 7 com.apple.AppKit 0x938f6520 -[NSOutlineView > _drawContentsAtRow:column:clipRect:] + 244 > 8 com.apple.AppKit 0x93850854 -[NSTableView > drawRow:clipRect:] + 220 > 9 com.apple.AppKit 0x938f6418 -[NSOutlineView > drawRow:clipRect:] + 184 > 10 com.apple.AppKit 0x93850610 -[NSTableView > drawRowIndexes:clipRect:] + 108 > 11 com.apple.AppKit 0x9384fc98 -[NSTableView > drawRect:] + 1144 > 12 com.apple.AppKit 0x937e4858 -[NSView > _drawRect:clip:] + 2128 > 13 com.apple.AppKit 0x937e3e18 -[NSView > _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 404 > 14 com.apple.AppKit 0x937e6b60 > _recursiveDisplayInRect2 + 84 > 15 com.apple.CoreFoundation 0x907ed3ec CFArrayApplyFunction + > 416 > 16 com.apple.AppKit 0x937e3f2c -[NSView > _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 680 > 17 com.apple.AppKit 0x937e6b60 > _recursiveDisplayInRect2 + 84 > 18 com.apple.CoreFoundation 0x907ed3ec CFArrayApplyFunction + > 416 > 19 com.apple.AppKit 0x937e3f2c -[NSView > _recursiveDisplayAllDirtyWithLockFocus:visRect:] + 680 > 20 com.apple.AppKit 0x937e33e0 -[NSView > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisible > RectForView:topView:] + 196 > 21 com.apple.AppKit 0x937e39a8 -[NSView > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisible > RectForView:topView:] + 1676 > 22 com.apple.AppKit 0x937e39a8 -[NSView > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisible > RectForView:topView:] + 1676 > 23 com.apple.AppKit 0x93804044 -[NSThemeFrame > _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisible > RectForView:topView:] + 192 > 24 com.apple.AppKit 0x937dd054 -[NSView > _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] > + 384 > 25 com.apple.AppKit 0x937d2348 -[NSView > displayIfNeeded] + 248 > 26 com.apple.AppKit 0x937d21b8 -[NSWindow > displayIfNeeded] + 180 > 27 com.apple.AppKit 0x937d2064 > _handleWindowNeedsDisplay + 200 > 28 com.apple.CoreFoundation 0x907dd76c __CFRunLoopDoObservers > + 352 > 29 com.apple.CoreFoundation 0x907dda0c __CFRunLoopRun + 420 > 30 com.apple.CoreFoundation 0x907dd4ac CFRunLoopRunSpecific + > 268 > 31 com.apple.HIToolbox 0x93298b20 > RunCurrentEventLoopInMode + 264 > 32 com.apple.HIToolbox 0x9329812c ReceiveNextEventCommon > + 244 > 33 com.apple.HIToolbox 0x93298020 > BlockUntilNextEventMatchingListInMode + 96 > 34 com.apple.AppKit 0x9379eae4 _DPSNextEvent + 384 > 35 com.apple.AppKit 0x9379e7a8 -[NSApplication > nextEventMatchingMask:untilDate:inMode:dequeue:] + 116 > 36 com.apple.AppKit 0x9379acec -[NSApplication run] + > 472 > 37 com.apple.AppKit 0x9388b87c NSApplicationMain + 452 > 38 com.apple.rubycocoa 0x0004227c ffi_call_DARWIN + 208 > 39 com.apple.rubycocoa 0x00041db4 ffi_call + 212 > 40 com.apple.rubycocoa 0x0003fbfc rb_ffi_dispatch + 5180 > 41 com.apple.rubycocoa 0x00038488 > find_bs_boxed_by_encoding + 1176 > 42 libruby.dylib 0x0022686c rb_call0 + 1180 > (eval.c:5848) > 43 libruby.dylib 0x002273e4 rb_call + 612 (eval.c: > 6096) > 44 libruby.dylib 0x002241ec rb_eval + 7468 (eval.c: > 3473) > 45 libruby.dylib 0x00234bbc ruby_exec_internal + > 172 (eval.c:1636) > 46 libruby.dylib 0x00234c08 ruby_exec + 24 (eval.c: > 1655) > 47 libruby.dylib 0x00234c58 ruby_run + 56 (eval.c: > 1665) > 48 com.apple.rubycocoa 0x000356f8 RBApplicationMain + 344 > 49 ....rubycocoa.OutlineMeRubyApp 0x000019c8 _start + 760 > 50 ....rubycocoa.OutlineMeRubyApp 0x000016cc start + 48 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a > browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |