Skip to content

Commit

Permalink
Fix class pair register on reload
Browse files Browse the repository at this point in the history
Summary: public

It was possible after reload to detach from the new instance, removing the markers.

Reviewed By: jspahrsummers

Differential Revision: D2696208

fb-gh-sync-id: ad8f5d449f51c7c74a20ae7c0cafc4fc786ea390
  • Loading branch information
tadeuzagallo authored and facebook-github-bot-3 committed Nov 26, 2015
1 parent 977a40e commit a7e2059
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions React/Profiler/RCTProfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ - (void)dispatchBlock:(dispatch_block_t)block
// This is actually a BOOL - but has to be compatible with OSAtomic
static volatile uint32_t RCTProfileProfiling;

static BOOL RCTProfileHookedModules;
static NSDictionary *RCTProfileInfo;
static NSMutableDictionary *RCTProfileOngoingEvents;
static NSTimeInterval RCTProfileStartTime;
Expand Down Expand Up @@ -210,19 +209,21 @@ void RCTProfileHookModules(RCTBridge *bridge)
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wtautological-pointer-compare"
if (RCTProfileTrampoline == NULL || RCTProfileHookedModules) {
if (RCTProfileTrampoline == NULL) {
return;
}
#pragma clang diagnostic pop

RCTProfileHookedModules = YES;

for (RCTModuleData *moduleData in [bridge valueForKey:@"moduleDataByID"]) {
[bridge dispatchBlock:^{
Class moduleClass = moduleData.moduleClass;
Class proxyClass = objc_allocateClassPair(moduleClass, RCTProfileProxyClassName(moduleClass), 0);

if (!proxyClass) {
proxyClass = objc_getClass(RCTProfileProxyClassName(moduleClass));
if (proxyClass) {
object_setClass(moduleData.instance, proxyClass);
}
return;
}

Expand Down Expand Up @@ -255,19 +256,12 @@ void RCTProfileHookModules(RCTBridge *bridge)

void RCTProfileUnhookModules(RCTBridge *bridge)
{
if (!RCTProfileHookedModules) {
return;
}

RCTProfileHookedModules = NO;

dispatch_group_enter(RCTProfileGetUnhookGroup());

for (RCTModuleData *moduleData in [bridge valueForKey:@"moduleDataByID"]) {
Class proxyClass = object_getClass(moduleData.instance);
if (moduleData.moduleClass != proxyClass) {
object_setClass(moduleData.instance, moduleData.moduleClass);
objc_disposeClassPair(proxyClass);
}
}

Expand Down

0 comments on commit a7e2059

Please sign in to comment.