[Rubycocoa-devel 891] Re: NSObject.alloc.init doesn't return NSObject sometimes

アーカイブの一覧に戻る

Laurent Sansonetti lsans****@apple*****
Thu May 24 01:44:38 JST 2007


Hi Satoshi-san,

I have problems reproducing the defect.

Here is the code I used:

<<<
require 'osx/cocoa'

OSX.require_framework 'WebKit'

include OSX

3000.times do |i|
   obj = NSObject.alloc.init
   if obj.class.name != 'OSX::NSObject'
     puts "Not NSObject at: #{i}"
     p obj
     return
   end
   view = WebView.alloc.initWithFrame(NSZeroRect)
   view.setPolicyDelegate(self)
   view.mainFrame.loadHTMLString_baseURL('<html></html>', nil)
end
puts 'No problem'
 >>>

It always prints "No problem" on 2 different environments (ppc and  
i386). I also tried to increase 3000 by a bigger number, without  
success.

# I also try your AllocDefect projet, without success too :(

Laurent

On May 23, 2007, at 7:43 AM, Satoshi Nakagawa wrote:

> Hi.
>
> I'm writing an application using WebKit. In the process I found a  
> defect of RubyCocoa.
>
> The defect is that NSObject.alloc.init doesn't return NSObject  
> sometimes. It is reproducible only when setting a ruby object for  
> WebPolicyDelegate or WebUIDelegate. If I set an Objective-C object  
> for WebPolicyDelegate, it works normally.
>
> In the following code, NSObject.alloc.init return  
> OSX::WebPolicyDecisionListener or OSX::NSMutableURLRequest sometimes.
>
> Environment: OSX 10.4 + ruby 1.8.2
> Reproducible versions: 0.10.1, 0.11.0
> NOT reproducible version: 0.5.0
>
> -------- Reproduce code
> class AppController < OSX::NSObject
>  include OSX
>
>  def  
> webView_decidePolicyForNavigationAction_request_frame_decisionListener 
> (sender, action, request, frame, listener)
>    listener.use
>  end
>
>  def awakeFromNib
>    puts '@@@ awakeFromNib'
>    3000.times do |i|
>      obj = NSObject.alloc.init
>      if obj.class.name != 'OSX::NSObject'
>        puts "Not NSObject at: #{i}"
>        p obj
>        return
>      end
>      view = WebView.alloc.initWithFrame(NSZeroRect)
>      view.setPolicyDelegate(self)
>      view.mainFrame.loadHTMLString_baseURL('<html></html>', nil)
>    end
> 	puts 'No problem'
>  end
> end
> --------
>
> -------- Result 1
> @@@ awakeFromNib
> Not NSObject at: 104
> #<OSX::WebPolicyDecisionListener:0x159ed6 class='NSObject'  
> id=0x500e20>
> --------
>
> -------- Result 2
> @@@ awakeFromNib
> Not NSObject at: 186
> #<OSX::NSMutableURLRequest:0x80d6f8 class='NSObject' id=0xd60bf60>
> --------
>
> The entire project contains the reproduce code:
>  http://limechat.net/rubycocoa/AllocRuby.zip
>
> And another project using Objective-C delegate object (it works  
> normally):
>  http://limechat.net/rubycocoa/AllocObjc.zip
>
> --
> Satoshi Nakagawa
> http://limechat.net/
> http://www.lingr.com/
>
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




More information about the Rubycocoa-devel mailing list
アーカイブの一覧に戻る