Skip to content

Commit

Permalink
fix: pass blocks with copy to retain them properly (#10298)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn authored and sgtcoolguy committed Sep 6, 2018
1 parent 6164fa4 commit 32d6eac
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions iphone/Classes/TiApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceAppl
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[self tryToInvokeSelector:@selector(application:performFetchWithCompletionHandler:)
withArguments:[NSOrderedSet orderedSetWithObjects:application, completionHandler, nil]];
withArguments:[NSOrderedSet orderedSetWithObjects:application, [completionHandler copy], nil]];

//Only for simulator builds
NSArray *backgroundModes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIBackgroundModes"];
Expand Down Expand Up @@ -647,7 +647,7 @@ - (void)application:(UIApplication *)application handleActionWithIdentifier:(NSS
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler
{
[self tryToInvokeSelector:@selector(application:handleActionWithIdentifier:forRemoteNotification:completionHandler:)
withArguments:[NSOrderedSet orderedSetWithObjects:application, identifier, userInfo, completionHandler, nil]];
withArguments:[NSOrderedSet orderedSetWithObjects:application, identifier, userInfo, [completionHandler copy], nil]];

[self handleRemoteNotificationWithIdentifier:identifier
andUserInfo:userInfo
Expand Down Expand Up @@ -678,7 +678,7 @@ - (void)application:(UIApplication *)application
}

[self tryToInvokeSelector:@selector(application:handleWatchKitExtensionRequest:reply:)
withArguments:[NSOrderedSet orderedSetWithObjects:application, userInfo, reply, nil]];
withArguments:[NSOrderedSet orderedSetWithObjects:application, userInfo, [reply copy], nil]];

[[NSNotificationCenter defaultCenter] postNotificationName:kTiWatchKitExtensionRequest object:self userInfo:dic];
}
Expand Down Expand Up @@ -730,7 +730,7 @@ - (void)tryToInvokeSelector:(SEL)selector withArguments:(NSOrderedSet<id> *)argu
[self invokeSelector:selector withArguments:arguments onDelegate:applicationDelegate];
}
}
} else {
} else if (!appBooted && _applicationDelegates == nil) {
[[self queuedApplicationSelectors] setObject:arguments forKey:selectorString];
}
}
Expand Down Expand Up @@ -836,7 +836,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N
}

[self tryToInvokeSelector:@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)
withArguments:[NSOrderedSet orderedSetWithObjects:application, userInfo, completionHandler, nil]];
withArguments:[NSOrderedSet orderedSetWithObjects:application, userInfo, [completionHandler copy], nil]];

//This only here for Simulator builds.

Expand Down Expand Up @@ -882,7 +882,7 @@ - (void)application:(UIApplication *)application handleEventsForBackgroundURLSes
[backgroundTransferCompletionHandlers setObject:[[completionHandler copy] autorelease] forKey:key];

[self tryToInvokeSelector:@selector(application:handleEventsForBackgroundURLSession:completionHandler:)
withArguments:[NSOrderedSet orderedSetWithObjects:application, identifier, completionHandler, nil]];
withArguments:[NSOrderedSet orderedSetWithObjects:application, identifier, [completionHandler copy], nil]];

NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:identifier, @"sessionId",
key, @"handlerId", nil];
Expand Down Expand Up @@ -1230,7 +1230,7 @@ - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserAct
[launchOptions setObject:userActivityDict forKey:UIApplicationLaunchOptionsUserActivityDictionaryKey];

[self tryToInvokeSelector:@selector(application:continueUserActivity:restorationHandler:)
withArguments:[NSOrderedSet orderedSetWithObjects:application, userActivity, restorationHandler, nil]];
withArguments:[NSOrderedSet orderedSetWithObjects:application, userActivity, [restorationHandler copy], nil]];

if (appBooted) {
[[NSNotificationCenter defaultCenter] postNotificationName:kTiContinueActivity object:self userInfo:dict];
Expand Down Expand Up @@ -1488,7 +1488,7 @@ - (void)application:(UIApplication *)application
completionHandler:(void (^)(BOOL succeeded))completionHandler
{
[self tryToInvokeSelector:@selector(application:performActionForShortcutItem:completionHandler:)
withArguments:[NSOrderedSet orderedSetWithObjects:application, shortcutItem, completionHandler, nil]];
withArguments:[NSOrderedSet orderedSetWithObjects:application, shortcutItem, [completionHandler copy], nil]];

BOOL handledShortCutItem = [self handleShortcutItem:shortcutItem queueToBootIfNotLaunched:NO];
completionHandler(handledShortCutItem);
Expand Down

0 comments on commit 32d6eac

Please sign in to comment.