From 0749a30ea0979b01c9f38cd71faf9541a907bfa1 Mon Sep 17 00:00:00 2001 From: Appcelerator Build Date: Tue, 23 Mar 2021 14:10:07 -0400 Subject: [PATCH] fix(ios): removing eventListener in location event will freeze app (#12645) Fixes TIMOB-28275 --- iphone/TitaniumKit/TitaniumKit/Sources/API/ObjcProxy.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); } }