rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

Eventable .off fix when using method(:my_method) syntax #399

Closed jsteinberg closed 10 years ago

jsteinberg commented 10 years ago

This PR contains a memory fix from PR(https://github.com/rubymotion/BubbleWrap/pull/398). Using ruby's method ==(http://ruby-doc.org/core-2.1.2/Method.html#method-i-3D-3D) is too strict when also using BubbleWrap::KVO.

From ruby-doc.org:

Two method objects are equal if they are bound to the same object and refer to the same method definition and their owners are the same class or module.

If you begin observing an object after creating an event with a method(:), it can change the owner property of method(:) when you go to take off the event.

This change relaxes the definition of == for method objects for removal.

clayallsopp commented 10 years ago

Heh, again very good detective work & spec - thanks!