[Rubycocoa-devel 1391] Re: object_id when fetching from NSArray

Zurück zum Archiv-Index

Allison Newman demal****@mac*****
Sat Apr 25 18:35:53 JST 2009


Hi Brian,

I'm really not sure what's going on here - it looks like it's a funny  
interaction between the ruby garbage collector, the rubycocoa proxy  
cache, and NSManagedObject.

Basically, if you manually cache the ruby side copy of the tiles, the  
bug never happens: the object stays in the proxy cache.  I've included  
some modified code from Puzzle.rb that shows this.

For my money, it's a bug in RubyCocoa's cache handling routines.  Have  
you found any other classes that do this, other than NSManagedObject?

On the same theme, if you replace $all in TileView by  
@puzzle.all_tiles, again, the bug goes away.  Basically, to me it  
looks like the buby-side proxy, which has had the functions added to  
it, is garbage collected, rather than being retained.

   def annotated(tiles)
     tiles.each do | tile |
       check_cache(tile)
       def tile.blank?
         entity.name == "BlankTile"
       end

       def tile.ending_position
         BoardPosition.for_tile(self, "correctXPosition",  
"correctYPosition")
       end

       def tile.current_position
         BoardPosition.for_tile(self, "xPosition", "yPosition")
       end
     end

     tiles
   end


   def check_cache(tile)
     cached_tile =****@cache*****{|t| t.__ocid__ == tile.__ocid__}
     if !cached_tile
       @cache << tile
     end
   end

   # Not relevant to bug description

   def init
     super_init
     @persistent_store = PersistentStore.alloc.init
     create_all_tiles if @persistent_store.fresh?
     @cache = []
     self
   end


Le 24 avr. 09 à 23:16, Brian Marick a écrit :

>
> On Apr 24, 2009, at 10:15 AM, Allison Newman wrote:
>
>> Do you have any code you can share that shows this bug?
>
> I've put the code here:
> http://github.com/marick/cocoa-examples-translated/tree/d70d44232278a2e4945417ee610c469feeff6452/rubycocoa/gotchas/singleton-death
>
> Clicking the download button on that page should give you an Xcode
> project that shows odd behavior. See the README.rtfd file for steps to
> reproduce.
>
>
>
>
> -----
> Brian Marick, independent consultant
> Mostly on agile methods with a testing slant
> www.exampler.com, www.exampler.com/blog, www.twitter.com/marick
>
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel

-------------- next part --------------
An HTML attachment was scrubbed...
Download 



More information about the Rubycocoa-devel mailing list
Zurück zum Archiv-Index