mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 22:50:21 +08:00
[Executor] Make executor ID functions non-static to fix ASan
Summary: When `RCTGetExecutorID` was a static function in the header file, it would return nil when the app was running with ASan enabled even though directly calling `objc_getAssociatedObject(executor, RCTJavaScriptExecutorID)` returned the correct ID as an NSNumber. Moving this function into the .m file fixes this issue. Closes https://github.com/facebook/react-native/pull/1712 Github Author: James Ide <ide@jameside.com> Test Plan: Run the UIExplorer with ASan enabled in Xcode 7. Before this diff, the app would just hang since the executor was unable to read a valid ID and so it would bail out from running JS. With this diff the executor runs the JS and the UIExplorer works fine.
This commit is contained in:
@@ -67,16 +67,5 @@ typedef void (^RCTJavaScriptCallback)(id json, NSError *error);
|
||||
|
||||
@end
|
||||
|
||||
static const char *RCTJavaScriptExecutorID = "RCTJavaScriptExecutorID";
|
||||
__used static void RCTSetExecutorID(id<RCTJavaScriptExecutor> executor)
|
||||
{
|
||||
static NSUInteger executorID = 0;
|
||||
if (executor) {
|
||||
objc_setAssociatedObject(executor, RCTJavaScriptExecutorID, @(++executorID), OBJC_ASSOCIATION_RETAIN);
|
||||
}
|
||||
}
|
||||
|
||||
__used static NSNumber *RCTGetExecutorID(id<RCTJavaScriptExecutor> executor)
|
||||
{
|
||||
return executor ? objc_getAssociatedObject(executor, RCTJavaScriptExecutorID) : @0;
|
||||
}
|
||||
void RCTSetExecutorID(id<RCTJavaScriptExecutor> executor);
|
||||
NSNumber *RCTGetExecutorID(id<RCTJavaScriptExecutor> executor);
|
||||
|
||||
Reference in New Issue
Block a user