Skip to content

Commit

Permalink
fix: pass blocks with copy to retain them properly (#10297)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn authored and sgtcoolguy committed Sep 6, 2018
1 parent 823670b commit 9b2dcd6
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 @@ -655,7 +655,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 @@ -686,7 +686,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 @@ -738,7 +738,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 @@ -844,7 +844,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 @@ -890,7 +890,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 @@ -1238,7 +1238,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 @@ -1496,7 +1496,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 9b2dcd6

Please sign in to comment.