From 2b9aaac2ff9868726e16f90b9de2af444ead230b Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Sat, 18 Apr 2015 06:23:24 -0700 Subject: [PATCH] [ReactNative] Guard against blocks being added to UIManager during dealloc --- React/Modules/RCTUIManager.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index b6a350dcd..ae04f9a1d 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -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); } };