Skip to content

Commit

Permalink
Merge pull request #1243 from sptramer/timob-7345-1_8_X
Browse files Browse the repository at this point in the history
[TIMOB-7345][TIMOB-7354][1_8_X] Notify delegates of value change
  • Loading branch information
WhichKatieDid committed Jan 25, 2012
2 parents 5283996 + 6d86f74 commit 5b6a3ed
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions iphone/Classes/TiProxy.m
Expand Up @@ -1000,26 +1000,32 @@ - (void)replaceValue:(id)value forKey:(NSString*)key notification:(BOOL)notify
value = nil;
}

// notify our delegate
if (current!=value)
{
BOOL newValue = (current != value && ![current isEqual:value]);

// We need to stage this out; the problem at hand is that some values
// we might store as properties (such as NSArray) use isEqual: as a
// strict address/hash comparison. So the notification must always
// occur, and it's up to the delegate to make sense of it (for now).

if (newValue) {
// Remember any proxies set on us so they don't get GC'd
if ([propvalue isKindOfClass:[TiProxy class]]) {
[self rememberProxy:propvalue];
}
[dynprops setValue:propvalue forKey:key];
pthread_rwlock_unlock(&dynpropsLock);
if (self.modelDelegate!=nil && notify)
{
[[(NSObject*)self.modelDelegate retain] autorelease];
[self.modelDelegate propertyChanged:key oldValue:current newValue:value proxy:self];
}
if ([current isKindOfClass:[TiProxy class]]) {
[self forgetProxy:current];
}
return; // so we don't unlock twice
}
}
pthread_rwlock_unlock(&dynpropsLock);

if (self.modelDelegate!=nil && notify)
{
[[(NSObject*)self.modelDelegate retain] autorelease];
[self.modelDelegate propertyChanged:key oldValue:current newValue:value proxy:self];
}

// Forget any old proxies so that they get cleaned up
if (newValue && [current isKindOfClass:[TiProxy class]]) {
[self forgetProxy:current];
}
}

// TODO: Shouldn't we be forgetting proxies and unprotecting callbacks and such here?
Expand Down

0 comments on commit 5b6a3ed

Please sign in to comment.