Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Changeset [3886f27acd04501083b1418c9a0faaedf45b16cf] by Ilya Kulakov

Revision 3886f27acd04501083b1418c9a0faaedf45b16cf, committed 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...

2 changed files

  • M Foundation/CPKeyValueObserving.j
  • M Tests/Foundation/CPKVOTest.j