mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 17:51:01 +00:00
Correct forwarding of changes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@25749 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
97d28c93f2
commit
73d0fc3a58
2 changed files with 43 additions and 23 deletions
|
@ -1,3 +1,8 @@
|
|||
2007-12-15 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSKeyValueObserving.m (-keyPathChanged:): Correct
|
||||
forwarding of changes.
|
||||
|
||||
2007-12-15 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSValueTransformer.m,
|
||||
|
|
|
@ -1026,10 +1026,6 @@ replacementForClass(Class c)
|
|||
|
||||
- (void) keyPathChanged: (id)objectToObserve
|
||||
{
|
||||
NSDictionary *change;
|
||||
id oldValue;
|
||||
id newValue;
|
||||
|
||||
if (objectToObserve != nil)
|
||||
{
|
||||
[observedObjectForUpdate removeObserver: self forKeyPath: keyForUpdate];
|
||||
|
@ -1040,35 +1036,54 @@ replacementForClass(Class c)
|
|||
| NSKeyValueObservingOptionOld
|
||||
context: target];
|
||||
}
|
||||
if (observedObjectForForwarding != nil)
|
||||
if (child != nil)
|
||||
{
|
||||
oldValue = [observedObjectForForwarding valueForKey: keyForForwarding];
|
||||
[observedObjectForForwarding removeObserver: self forKeyPath:
|
||||
keyForForwarding];
|
||||
[child keyPathChanged:
|
||||
[observedObjectForUpdate valueForKey: keyForUpdate]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMutableDictionary *change;
|
||||
|
||||
change = [NSMutableDictionary dictionaryWithObject:
|
||||
[NSNumber numberWithInt: 1]
|
||||
forKey: NSKeyValueChangeKindKey];
|
||||
|
||||
if (observedObjectForForwarding != nil)
|
||||
{
|
||||
id oldValue;
|
||||
|
||||
oldValue = [observedObjectForForwarding valueForKey: keyForForwarding];
|
||||
[observedObjectForForwarding removeObserver: self forKeyPath:
|
||||
keyForForwarding];
|
||||
if (oldValue)
|
||||
{
|
||||
[change setObject: oldValue forKey: NSKeyValueChangeOldKey];
|
||||
}
|
||||
}
|
||||
observedObjectForForwarding = [observedObjectForUpdate
|
||||
valueForKey:keyForUpdate];
|
||||
[observedObjectForForwarding addObserver: self
|
||||
forKeyPath: keyForForwarding
|
||||
if (observedObjectForForwarding != nil)
|
||||
{
|
||||
id newValue;
|
||||
|
||||
[observedObjectForForwarding addObserver: self
|
||||
forKeyPath: keyForForwarding
|
||||
options: NSKeyValueObservingOptionNew
|
||||
| NSKeyValueObservingOptionOld
|
||||
| NSKeyValueObservingOptionOld
|
||||
context: target];
|
||||
//prepare change notification
|
||||
newValue = [observedObjectForForwarding valueForKey: keyForForwarding];
|
||||
change = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInt: 1], NSKeyValueChangeKindKey,
|
||||
oldValue, NSKeyValueChangeOldKey,
|
||||
newValue, NSKeyValueChangeNewKey,
|
||||
nil];
|
||||
//prepare change notification
|
||||
newValue = [observedObjectForForwarding valueForKey: keyForForwarding];
|
||||
if (newValue)
|
||||
{
|
||||
[change setObject: newValue forKey: NSKeyValueChangeNewKey];
|
||||
}
|
||||
}
|
||||
[target observeValueForKeyPath: keyPathToForward
|
||||
ofObject: observedObjectForUpdate
|
||||
change: change
|
||||
context: contextToForward];
|
||||
}
|
||||
else
|
||||
{
|
||||
[child keyPathChanged:
|
||||
[observedObjectForUpdate valueForKey: keyForUpdate]];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue