CB-4995 Fix crash when WebView is quickly opened then closed.

Also fixes a leak where callback was never being cleared.
This commit is contained in:
Andrew Grieve 2013-10-21 13:16:54 -04:00
parent c7972b6cff
commit aa81c3267a

View File

@ -56,12 +56,8 @@
- (void)close:(CDVInvokedUrlCommand*)command - (void)close:(CDVInvokedUrlCommand*)command
{ {
if (self.inAppBrowserViewController != nil) { // Things are cleaned up in browserExit.
[self.inAppBrowserViewController close]; [self.inAppBrowserViewController close];
self.inAppBrowserViewController = nil;
}
self.callbackId = nil;
} }
- (BOOL) isSystemUrl:(NSURL*)url - (BOOL) isSystemUrl:(NSURL*)url
@ -372,14 +368,15 @@
if (self.callbackId != nil) { if (self.callbackId != nil) {
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:@{@"type":@"exit"}]; messageAsDictionary:@{@"type":@"exit"}];
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId]; [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. // 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. // Also - this is required for the PDF/User-Agent bug work-around.
self.inAppBrowserViewController = nil; self.inAppBrowserViewController = nil;
if (IsAtLeastiOSVersion(@"7.0")) { if (IsAtLeastiOSVersion(@"7.0")) {
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle]; [[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
} }