[MacRuby] #312: reopening a class and setNeedsDisplay: segfault
#312: reopening a class and setNeedsDisplay: segfault -------------------------------------+-------------------------------------- Reporter: mattaimonetti@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- {{{ framework 'Cocoa' class ImageLayer < CALayer; def initialize(file_name); super(); end; end ImageLayer.new('test').setNeedsDisplay }}} unknown: [BUG] Segmentation fault The same class, without the modified initializer works fine: {{{ class ImageLayer < CALayer; def initialize; super(); end; end ImageLayer.new.setNeedsDisplay # => nil }}} Interesting enough: {{{ class ImageLayer < CALayer; def initialize(file_name); super(); end; end ImageLayer.new('test') #=> #<ImageLayer:0x8004963c0> }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/312> MacRuby <http://macruby.org/>
#312: reopening a class and setNeedsDisplay: segfault -------------------------------------+-------------------------------------- Reporter: mattaimonetti@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Comment(by martinlagardette@…): Also, getting rid of `super()` parenthesis: {{{ #!ruby framework 'Cocoa' class ImageLayer < CALayer; def initialize(file_name); super; end; end ImageLayer.new('test').setNeedsDisplay }}} {{{ /private/tmp/t.rb:2:in `initialize:': super: no superclass method `initialize' for #<ImageLayer:0x2005b5460> (NoMethodError) from /private/tmp/t.rb:1:in `<main>' }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/312#comment:1> MacRuby <http://macruby.org/>
#312: reopening a class and setNeedsDisplay: segfault -------------------------------------+-------------------------------------- Reporter: mattaimonetti@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: critical | Milestone: MacRuby 0.5 Component: MacRuby | Resolution: invalid Keywords: | -------------------------------------+-------------------------------------- Changes (by martinlagardette@…): * status: new => closed * resolution: => invalid Comment: Also, I would suggest doing something more Cocoa-y, to make sure `CALayer` `-init` is called: {{{ #!ruby framework 'Cocoa' class ImageLayer < CALayer def initialize(file_name) if init @filename = file_name end self end end ImageLayer.new("test").setNeedsDisplay }}} This will actually call `CALayer`'s `-init`, which I think is not called at all in your 1st and 3rd example, hence the crash in `-setNeedsDisplay`, the `CALayer` not being initalized properly. In the second example you linked, `initialize` is never called, so `-init` is actually called and that's why it works. You can see by doing: {{{ #!ruby framework 'Cocoa' class ImageLayer < CALayer; def initialize; super(); p "rb init"; end; end ImageLayer.new.setNeedsDisplay # => nil }}} {{{ $> macruby t.rb $> }}} I'll close this bug, but feel free to re-open it if I'm wrong / if I missed something :-) -- Ticket URL: <http://www.macruby.org/trac/ticket/312#comment:2> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby