From: Brian M. <ma...@ex...> - 2008-09-11 03:52:19
|
I'm making my own NSFormatter subclass. It defines isPartialStringValid:newEditingString:errorDescription:, which returns a BOOL (and also takes two ObjcPtr arguments). The symptom is that the window (a preference panel) disappears after repeated calls to the method (repeated keypresses in the text box the formatter formats). The application doesn't crash. The window is loaded from its own nib. It happens if the method returns true/false (The real literals, not, say, nil for falseness.) It happens if the method returns fixnums 0/1. Adding a to_ns to the return value doesn't make a difference. The particular sequence of characters that causes the crash changes if you put NSLog statements in the method - so it's like something's scribbling over memory. Some NSLog statements make the problem (appear to) go away. Here's what the method looks like: def isPartialStringValid_newEditingString_errorDescription(s, new_s, errdesc) # NSLog s.inspect matcher = Regexp.new('^'+s.to_ruby.downcase) val = matcher =~ 'yes' || matcher =~ 'no' val = (val ? 1 : 0).to_ns # val = (!!val).to_ns # NSLog val.inspect # NSLog "#{val.class} #{val.inspect}" val end Ideas? I'm running 0.13.1. ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.exampler.com/blog, www.twitter.com/marick |