no-op if module has been deallocated

This commit is contained in:
Ari Lazier 2015-11-16 17:57:06 -08:00
parent 159931e4ec
commit 52fa3e8b1c
1 changed files with 10 additions and 5 deletions

View File

@ -60,9 +60,10 @@ JSGlobalContextRef RealmReactGetJSGlobalContextForExecutor(id executor, bool cre
@end
#endif
@interface RealmReact () <RCTBridgeModule>
@property (weak) NSThread *currentJSThread;
@property (weak) NSRunLoop *currentJSRunLoop;
@interface RealmReact () <RCTBridgeModule> {
__weak NSThread *_currentJSThread;
__weak NSRunLoop *_currentJSRunLoop;
}
@end
static __weak RealmReact *s_currentRealmModule = nil;
@ -183,8 +184,12 @@ static __weak RealmReact *s_currentRealmModule = nil;
else {
__weak __typeof__(self) weakSelf = self;
[executor executeBlockOnJavaScriptQueue:^{
weakSelf.currentJSThread = [NSThread currentThread];
weakSelf.currentJSRunLoop = [NSRunLoop currentRunLoop];
RealmReact *self = weakSelf;
if (!self) {
return;
}
self->_currentJSThread = [NSThread currentThread];
self->_currentJSRunLoop = [NSRunLoop currentRunLoop];
JSGlobalContextRef ctx = RealmReactGetJSGlobalContextForExecutor(executor, true);
RJSInitializeInContext(ctx);
}];