From 3ab4d32538fac43c7dd2320354e30e2e3c07aca3 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Tue, 5 May 2015 07:27:40 -0700 Subject: [PATCH] [ReactNative] Fix DevMenu crash when launching the app with WebView executor --- React/Base/RCTDevMenu.m | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/React/Base/RCTDevMenu.m b/React/Base/RCTDevMenu.m index 6c64e4677..d2e4b7416 100644 --- a/React/Base/RCTDevMenu.m +++ b/React/Base/RCTDevMenu.m @@ -123,11 +123,17 @@ RCT_EXPORT_MODULE() { _settings = [NSMutableDictionary dictionaryWithDictionary:[_defaults objectForKey:RCTDevMenuSettingsKey]]; + __weak RCTDevMenu *weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ - self.shakeToShow = [_settings[@"shakeToShow"] ?: @YES boolValue]; - self.profilingEnabled = [_settings[@"profilingEnabled"] ?: @NO boolValue]; - self.liveReloadEnabled = [_settings[@"liveReloadEnabled"] ?: @NO boolValue]; - self.executorClass = NSClassFromString(_settings[@"executorClass"]); + RCTDevMenu *strongSelf = weakSelf; + if (!strongSelf) { + return; + } + + strongSelf.shakeToShow = [strongSelf->_settings[@"shakeToShow"] ?: @YES boolValue]; + strongSelf.profilingEnabled = [strongSelf->_settings[@"profilingEnabled"] ?: @NO boolValue]; + strongSelf.liveReloadEnabled = [strongSelf->_settings[@"liveReloadEnabled"] ?: @NO boolValue]; + strongSelf.executorClass = NSClassFromString(strongSelf->_settings[@"executorClass"]); }); }