From aa81c3267a5b1c337b09933ff5ceb06a93f9dbb7 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Mon, 21 Oct 2013 13:16:54 -0400 Subject: [PATCH] CB-4995 Fix crash when WebView is quickly opened then closed. Also fixes a leak where callback was never being cleared. --- src/ios/CDVInAppBrowser.m | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 5711e76..4ef051f 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -56,12 +56,8 @@ - (void)close:(CDVInvokedUrlCommand*)command { - if (self.inAppBrowserViewController != nil) { - [self.inAppBrowserViewController close]; - self.inAppBrowserViewController = nil; - } - - self.callbackId = nil; + // Things are cleaned up in browserExit. + [self.inAppBrowserViewController close]; } - (BOOL) isSystemUrl:(NSURL*)url @@ -372,14 +368,15 @@ if (self.callbackId != nil) { CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"type":@"exit"}]; - [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]]; - [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId]; + self.callbackId = nil; } + // Set navigationDelegate to nil to ensure no callbacks are received from it. + self.inAppBrowserViewController.navigationDelegate = nil; // Don't recycle the ViewController since it may be consuming a lot of memory. // Also - this is required for the PDF/User-Agent bug work-around. self.inAppBrowserViewController = nil; - + if (IsAtLeastiOSVersion(@"7.0")) { [[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle]; }