[ReactNative] Guard against blocks being added to UIManager during dealloc

This commit is contained in:
Tadeu Zagallo 2015-04-18 06:23:24 -07:00
parent bd5b12c535
commit 2b9aaac2ff
1 changed files with 6 additions and 4 deletions

View File

@ -398,13 +398,15 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
{
RCTAssert(![NSThread isMainThread], @"This method should only be called on the shadow thread");
if (!self.isValid) {
return;
}
__weak RCTUIManager *weakViewManager = self;
__weak RCTSparseArray *weakViewRegistry = _viewRegistry;
dispatch_block_t outerBlock = ^{
RCTUIManager *strongViewManager = weakViewManager;
RCTSparseArray *strongViewRegistry = weakViewRegistry;
if (strongViewManager && strongViewRegistry) {
block(strongViewManager, strongViewRegistry);
if (strongViewManager && strongViewManager.isValid) {
block(strongViewManager, strongViewManager->_viewRegistry);
}
};