mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 09:41:15 +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>
|
2007-12-15 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSValueTransformer.m,
|
* Source/NSValueTransformer.m,
|
||||||
|
|
|
@ -1026,10 +1026,6 @@ replacementForClass(Class c)
|
||||||
|
|
||||||
- (void) keyPathChanged: (id)objectToObserve
|
- (void) keyPathChanged: (id)objectToObserve
|
||||||
{
|
{
|
||||||
NSDictionary *change;
|
|
||||||
id oldValue;
|
|
||||||
id newValue;
|
|
||||||
|
|
||||||
if (objectToObserve != nil)
|
if (objectToObserve != nil)
|
||||||
{
|
{
|
||||||
[observedObjectForUpdate removeObserver: self forKeyPath: keyForUpdate];
|
[observedObjectForUpdate removeObserver: self forKeyPath: keyForUpdate];
|
||||||
|
@ -1040,35 +1036,54 @@ replacementForClass(Class c)
|
||||||
| NSKeyValueObservingOptionOld
|
| NSKeyValueObservingOptionOld
|
||||||
context: target];
|
context: target];
|
||||||
}
|
}
|
||||||
if (observedObjectForForwarding != nil)
|
if (child != nil)
|
||||||
{
|
{
|
||||||
oldValue = [observedObjectForForwarding valueForKey: keyForForwarding];
|
[child keyPathChanged:
|
||||||
[observedObjectForForwarding removeObserver: self forKeyPath:
|
[observedObjectForUpdate valueForKey: keyForUpdate]];
|
||||||
keyForForwarding];
|
}
|
||||||
|
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
|
observedObjectForForwarding = [observedObjectForUpdate
|
||||||
valueForKey:keyForUpdate];
|
valueForKey:keyForUpdate];
|
||||||
[observedObjectForForwarding addObserver: self
|
if (observedObjectForForwarding != nil)
|
||||||
forKeyPath: keyForForwarding
|
{
|
||||||
|
id newValue;
|
||||||
|
|
||||||
|
[observedObjectForForwarding addObserver: self
|
||||||
|
forKeyPath: keyForForwarding
|
||||||
options: NSKeyValueObservingOptionNew
|
options: NSKeyValueObservingOptionNew
|
||||||
| NSKeyValueObservingOptionOld
|
| NSKeyValueObservingOptionOld
|
||||||
context: target];
|
context: target];
|
||||||
//prepare change notification
|
//prepare change notification
|
||||||
newValue = [observedObjectForForwarding valueForKey: keyForForwarding];
|
newValue = [observedObjectForForwarding valueForKey: keyForForwarding];
|
||||||
change = [NSDictionary dictionaryWithObjectsAndKeys:
|
if (newValue)
|
||||||
[NSNumber numberWithInt: 1], NSKeyValueChangeKindKey,
|
{
|
||||||
oldValue, NSKeyValueChangeOldKey,
|
[change setObject: newValue forKey: NSKeyValueChangeNewKey];
|
||||||
newValue, NSKeyValueChangeNewKey,
|
}
|
||||||
nil];
|
}
|
||||||
[target observeValueForKeyPath: keyPathToForward
|
[target observeValueForKeyPath: keyPathToForward
|
||||||
ofObject: observedObjectForUpdate
|
ofObject: observedObjectForUpdate
|
||||||
change: change
|
change: change
|
||||||
context: contextToForward];
|
context: contextToForward];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
[child keyPathChanged:
|
|
||||||
[observedObjectForUpdate valueForKey: keyForUpdate]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue