Fix for KVC memory leak; found by Dirk Theisen

This commit is contained in:
Johannes Fortmann 2008-04-30 13:25:47 +00:00
parent 2b7e272164
commit 78c737cd18
2 changed files with 6 additions and 0 deletions

View File

@ -47,7 +47,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(id)_representedObject
{
if(accessor)
{
return accessor(proxyObject, accessorSel);
}
return [proxyObject valueForKey:key];
}
@ -96,7 +98,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
- (void)insertObject:(id)anObject atIndex:(unsigned)index;
{
if(insert)
{
insert(proxyObject, insertSel, anObject, index);
}
else
{
id target=[[self _representedObject] mutableCopy];

View File

@ -181,6 +181,7 @@ static NSLock *kvoLock=nil;
[dict setObject:[NSNumber numberWithInt:NSKeyValueChangeSetting]
forKey:NSKeyValueChangeKindKey];
[self _willChangeValueForKey:key changeOptions:dict];
[dict release];
}
-(void)didChangeValueForKey:(NSString*)key
@ -196,6 +197,7 @@ static NSLock *kvoLock=nil;
[dict setObject:indexes
forKey:NSKeyValueChangeIndexesKey];
[self _willChangeValueForKey:key changeOptions:dict];
[dict release];
}
- (void)didChange:(NSKeyValueChange)change valuesAtIndexes:(NSIndexSet *)indexes forKey:(NSString *)key