Laurent Sansonetti
lsans****@apple*****
Tue Jan 2 23:20:14 JST 2007
Hi, Chris reported a problem when returning pure Ruby objects (that do not inherit from OSX::NSObject) to NSOutlineView. The problem is that NSOutlineView expects you to return always the same objects (this is by design), but RubyCocoa was at some point releasing the RBObject instances. I found that RBObject objects were created as autorelease, and that the proxied Ruby object was retained during the RBObject life, which is probably something we don't want. Instead, I did the opposite: the RBObject objects are created with a refcount of 1 (simple alloc/init) and they are autoreleased when the proxied Ruby object has been collected (using ObjectSpace#define_finalizer), which makes more sense to me. I added the fix to SVN, if you can look at it it would be great. Laurent Begin forwarded message: > From: Laurent Sansonetti <lsans****@apple*****> > Date: December 28, 2006 9:03:29 PM CEST > To: rubyc****@lists***** > Subject: Re: [Rubycocoa-talk] NSOutlineView crashing when trying to > expand > Reply-To: rubyc****@lists***** > > Hi Chris, > > On Dec 28, 2006, at 8:27 PM, Chris McGrath wrote: > >> On 28 Dec 2006, at 17:17, Laurent Sansonetti wrote: >>> Changing your TestData definition like this should fix the problem. >>> >>> <snipped code> >> >> Yep, that worked, thanks Laurent. Unfortunately in my real app, the >> TestData objects are actually ActiveRecord objects, so I can't make >> them inherit from NSObject. I guess I'll either need to implement my >> own NSObject derived proxy for the AR objects for display, or look >> at just using CoreData. My app became a bit of a frankenapp with all >> the rails stuff I needed to include to get AR "working" anyway so >> CoreData is probably a saner bet. It looks like the ActiveSupport >> reloading stuff and RubyCocoa don't play well together. I could get >> different errors just by changing which was included first until I >> figured out how to hack the AR side enough to make some progress. >> >> I think i'll try with my own proxy objects this evening anyway, just >> to see how far I can get. > > In fact, I wonder why RubyCocoa eliminates the proxies, it might > simply be a bug in our side. I will investigate a bit later (I drank > too much beer for today :-)), it might also be interesting to provide > a sample code with an ActiveRecord-based NSOutlineView. > > Laurent > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to > share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Rubycocoa-talk mailing list > Rubyc****@lists***** > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk