Fix retain cycle in RCTDevMenu

Summary: A retain-cycle regression was added by D14162776 and detected here: T41208740. Fix should be trivial.

Reviewed By: shergin

Differential Revision: D14709784

fbshipit-source-id: bad6ab31a5170e9320c4432cbd20d02ec6164f38
This commit is contained in:
Joshua Gross
2019-04-01 13:41:52 -07:00
committed by Facebook Github Bot
parent 2a80a42d40
commit 1b51cd488a

View File

@@ -204,6 +204,7 @@ RCT_EXPORT_MODULE()
// Add built-in items
__weak RCTBridge *bridge = _bridge;
__weak RCTDevSettings *devSettings = _bridge.devSettings;
__weak RCTDevMenu *weakSelf = self;
[items addObject:[RCTDevMenuItem buttonItemWithTitle:@"Reload" handler:^{
[bridge reload];
@@ -296,7 +297,7 @@ RCT_EXPORT_MODULE()
textField.placeholder = @"index";
}];
[alertController addAction:[UIAlertAction actionWithTitle:@"Use bundled JS" style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction *action) {
[self setDefaultJSBundle];
[weakSelf setDefaultJSBundle];
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Use packager location" style:UIAlertActionStyleDefault handler:^(__unused UIAlertAction *action) {
NSArray * textfields = alertController.textFields;
@@ -308,7 +309,7 @@ RCT_EXPORT_MODULE()
bundleRoot = @"index";
}
if(ipTextField.text.length == 0 && portTextField.text.length == 0) {
[self setDefaultJSBundle];
[weakSelf setDefaultJSBundle];
return;
}
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
@@ -319,8 +320,11 @@ RCT_EXPORT_MODULE()
}
[RCTBundleURLProvider sharedSettings].jsLocation = [NSString stringWithFormat:@"%@:%d",
ipTextField.text, portNumber.intValue];
self->_bridge.bundleURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:bundleRoot fallbackResource:nil];
[self->_bridge reload];
__strong RCTBridge *strongBridge = bridge;
if (strongBridge) {
strongBridge.bundleURL = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:bundleRoot fallbackResource:nil];
[strongBridge reload];
}
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(__unused UIAlertAction *action) {
return;