Skip to content

Commit

Permalink
fix: pass blocks with copy to retain them properly (#10296)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Sep 1, 2018
1 parent 74bb07e commit 85e255d
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 @@ -561,7 +561,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 @@ -663,7 +663,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 @@ -694,7 +694,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 @@ -746,7 +746,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 @@ -854,7 +854,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 @@ -900,7 +900,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 @@ -1259,7 +1259,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 @@ -1518,7 +1518,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 85e255d

Please sign in to comment.