diff --git a/iphone/TitaniumKit/TitaniumKit/Sources/API/ObjcProxy.m b/iphone/TitaniumKit/TitaniumKit/Sources/API/ObjcProxy.m index b5263558b1d..eb24fee85d4 100644 --- a/iphone/TitaniumKit/TitaniumKit/Sources/API/ObjcProxy.m +++ b/iphone/TitaniumKit/TitaniumKit/Sources/API/ObjcProxy.m @@ -251,9 +251,12 @@ - (void)fireEvent:(NSString *)name withDict:(NSDictionary *)dict pthread_rwlock_rdlock(&_listenerLock); @try { if (_listeners == nil) { + pthread_rwlock_unlock(&_listenerLock); return; } - NSArray *listenersForType = [_listeners objectForKey:name]; + NSArray *listenersForType = [[_listeners objectForKey:name] copy]; + pthread_rwlock_unlock(&_listenerLock); + if (listenersForType == nil) { return; } @@ -261,9 +264,9 @@ - (void)fireEvent:(NSString *)name withDict:(NSDictionary *)dict for (JSValue *storedCallback in listenersForType) { [self _fireEventToListener:name withObject:dict listener:storedCallback]; } + [listenersForType autorelease]; } @finally { - pthread_rwlock_unlock(&_listenerLock); } }