mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-07 09:17:55 +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:
26
React/Base/RCTJavaScriptExecutor.m
Normal file
26
React/Base/RCTJavaScriptExecutor.m
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTJavaScriptExecutor.h"
|
||||
|
||||
|
||||
static const char *RCTJavaScriptExecutorID = "RCTJavaScriptExecutorID";
|
||||
|
||||
void RCTSetExecutorID(id<RCTJavaScriptExecutor> executor)
|
||||
{
|
||||
static NSUInteger executorID = 0;
|
||||
if (executor) {
|
||||
objc_setAssociatedObject(executor, RCTJavaScriptExecutorID, @(++executorID), OBJC_ASSOCIATION_RETAIN);
|
||||
}
|
||||
}
|
||||
|
||||
NSNumber *RCTGetExecutorID(id<RCTJavaScriptExecutor> executor)
|
||||
{
|
||||
return executor ? objc_getAssociatedObject(executor, RCTJavaScriptExecutorID) : @0;
|
||||
}
|
||||
Reference in New Issue
Block a user