[MacRuby-devel] [MacRuby] #723: nsset + bindings error

MacRuby ruby-noreply at macosforge.org
Wed May 19 14:45:24 PDT 2010


#723: nsset + bindings error
-----------------------------------+----------------------------------------
 Reporter:  jakub.suder@…          |       Owner:  lsansonetti@…        
     Type:  defect                 |      Status:  new                  
 Priority:  major                  |   Milestone:                       
Component:  MacRuby                |    Keywords:                       
-----------------------------------+----------------------------------------
 I have a weird error related to NSSet.setWithObjects method and bindings.
 I'm not sure exactly what causes it, but my guess is that it's some kind
 of problem with methods that accept variable number of arguments, that
 only appears in some specific conditions. It took me a few hours to
 isolate only the relevant code, but I managed to cut it down to two small
 classes where changing anything else makes the error disappear (see
 attached zip with a project).

 So I have a model class with 3 fields and 2 helper methods using those
 fields. For those 2 helper methods, I provide KVO methods
 keyPathsForValuesAffecting*** returning sets. In the app delegate, I
 create one instance of that class and 2 views, and bind two properties of
 the views to the methods in the model object.

 When I get to NSSet.setWithObjects("sender", "recipient", nil) in
 keyPathsForValuesAffectingSenderAndRecipient, the application hangs.

 Now, if I change anything in this code, it stops hanging; for example:
 - if I use NSSet.setWithArray(["sender", "recipient"]), it works
 - if I use a set with just "sender" (NSSet.setWithObjects("sender", nil)),
 it works
 - if I delete the second KVO method
 (keyPathsForValuesAffectingHasPicture), the first one starts working
 - if I don't bind the first view to keyPathsForValuesAffectingHasPicture,
 or change the order of bindings, it starts working
 - if I return a 2-element set in keyPathsForValuesAffectingHasPicture, it
 starts working (?!)
 - and here's the funniest one: if I copy the line
 NSSet.setWithObjects("sender", "recipient", nil) to application delegate,
 before the bindings, it works there, and the original invocation inside
 keyPathsForValuesAffectingSenderAndRecipient also magically starts working
 (?!?!)

 As you can see, it's hard to figure out what's going on here... But as far
 as I can tell, this smells to me like some kind of bug related to memory,
 pointers pointing to wrong places and so on... (oh, good old C times... :)

 And BTW, if I rewrite the model class (Message) in ObjC, it also starts
 working.

 Tested on MacRuby 0.6.

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/723>
MacRuby <http://macruby.org/>



More information about the MacRuby-devel mailing list