Changeset [3886f27acd04501083b1418c9a0faaedf45b16cf] by Ilya Kulakov

July 14th, 2012 @ 02:32 AM

Fix crash if an observer is set between willChange…/didChange…

When you add an observer to an object first time, its class is
implicitly changed to a KVO_originalClassName (subclass of original
class). This subclass adds willChange…/didChange… methods for
observable properties.
If you send willChange… before you add an observer, it does nothing.
But if you send didChange… just after, the app will crash, because
new KVO_originalClassName nerver receives willChange…

The idea is to maintain counter of all received willChange… messages
(per key) and decrease it in didChange… When KVO_originalClassName is created and didChange… is received
(without opening willChange… to new class), exception is not thrown immediately, but the counter is checked first.
If it's greater than 0, then didChange… just closes
an unboserved willChange… Otherwise exception is thrown, as expected.
https://github.com/cappuccino/cappuccino/commit/3886f27acd04501083b...

Committed by Ilya Kulakov

  • M Foundation/CPKeyValueObserving.j
  • M Tests/Foundation/CPKVOTest.j
New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Cappuccino Web Framework, including AppKit, Foundation, and Objective-J.

Shared Ticket Bins