[Rubycocoa-devel 250] Re: [Rubycocoa-talk] PATCH: fix retain-before-init problem

Back to archive index

Jonathan Paisley jp-ww****@dcs*****
Thu May 4 07:22:38 JST 2006


Hi Laurent,

Many thanks for your patches. I've moved this message onto the -devel  
mailing list.

Sorry I haven't replied sooner. I've just started a new job and  
things are rather hectic!

More replies below:

On 3 May 2006, at 14:25, Laurent Sansonetti wrote:

> I found a bug in the latest patch (Symbol-to-C-String conversion),  
> here is a new revision.
>
> BTW I found in the archives that this bug has been investigated in  
> the past (sorry I should have read the archives first...).  Perhaps  
> it is already fixed in the developer CVS?

It hasn't been fixed yet. I had a go at working around the problem  
for NSView but later realised that it would require more  
restructuring to solve it properly. Since then I haven't had the  
opportunity to investigate further.

I've had a look at the patch but not tested it yet. I've got a few  
questions:

1. Could you describe the invariants that you've introduced with  
respect to the retain count/ownership of the 'ocid' object in the  
_objcid_data structure, depending on the value of the 'initialized'  
field? Perhaps the best way to do this would be to add comments at  
the relevant parts of the code.

2. Could you add a comment describing the logic/meaning of the new  
'if/else if' towards the end of 'ocm_send()'?

Thanks again for your work on this.

Below are the two work-in-progress files I had as test cases for the  
specific case of fixing the NSView-triggered console log messages. Of  
course, this was just a visible complaint for the deeper problem that  
you are tackling.

Cheers,
Jonathan

#####################
# FILE: tests/tc_nsview.rb
require 'test/unit'
require 'osx/cocoa'

class TC_NSView < Test::Unit::TestCase
   include OSX

   def test_view_retainCount
     v = NSView.alloc
     assert_equal 1, v.retainCount
     v = v.initWithFrame([0,0,100,100])
     assert_equal 1, v.retainCount
   end

   def xtest_view_derived_retainCount
     v = NSTableView.alloc
     assert_equal 1, v.retainCount
     v = v.initWithFrame([0,0,100,100])
     assert_equal 1, v.retainCount
   end

   def test_other_retainCount
     d = NSMutableData.alloc
     assert_equal 2, d.retainCount
     d = d.initWithCapacity(10)
     assert_equal 1, d.retainCount
   end

   def test_logged_output
     result = `ruby nsview_log.rb 2>&1`
     assert_match /nsview_log exiting/, result
     assert_no_match /NSView not correctly/, result
   end

end

#####################
# FILE: tests/nsview_log.rb
require 'osx/cocoa'
OSX::NSView.alloc.initWithFrame([0,0,100,100])
puts "nsview_log exiting"






More information about the Rubycocoa-devel mailing list
Back to archive index