CB-6837 Fix leaked window when hitting back button while alert being rendered

Keep track of the last AlertDialog showed.
The last dialog showed that is rendered while hitting back button it
causes a leaked window.
Instead of perform a full track of all dialogs created, only destroy the
last one showed, this fixes the problem.

close #122
This commit is contained in:
Martin Gonzalez 2014-10-03 00:47:13 -05:00 committed by Andrew Grieve
parent 6cbf6b7875
commit 890e12c306
2 changed files with 16 additions and 3 deletions

View File

@ -65,6 +65,9 @@ public class CordovaChromeClient extends WebChromeClient {
// the video progress view // the video progress view
private View mVideoProgressView; private View mVideoProgressView;
//Keep track of last AlertDialog showed
private AlertDialog lastHandledDialog;
// File Chooser // File Chooser
public ValueCallback<Uri> mUploadMessage; public ValueCallback<Uri> mUploadMessage;
@ -123,7 +126,7 @@ public class CordovaChromeClient extends WebChromeClient {
return true; return true;
} }
}); });
dlg.show(); lastHandledDialog = dlg.show();
return true; return true;
} }
@ -172,7 +175,7 @@ public class CordovaChromeClient extends WebChromeClient {
return true; return true;
} }
}); });
dlg.show(); lastHandledDialog = dlg.show();
return true; return true;
} }
@ -216,7 +219,7 @@ public class CordovaChromeClient extends WebChromeClient {
res.cancel(); res.cancel();
} }
}); });
dlg.show(); lastHandledDialog = dlg.show();
} }
return true; return true;
} }
@ -328,4 +331,11 @@ public class CordovaChromeClient extends WebChromeClient {
public ValueCallback<Uri> getValueCallback() { public ValueCallback<Uri> getValueCallback() {
return this.mUploadMessage; return this.mUploadMessage;
} }
public void destroyLastDialog(){
if(lastHandledDialog != null){
lastHandledDialog.cancel();
}
}
} }

View File

@ -788,6 +788,9 @@ public class CordovaWebView extends WebView {
// Load blank page so that JavaScript onunload is called // Load blank page so that JavaScript onunload is called
this.loadUrl("about:blank"); this.loadUrl("about:blank");
//Remove last AlertDialog
this.chromeClient.destroyLastDialog();
// Forward to plugins // Forward to plugins
if (this.pluginManager != null) { if (this.pluginManager != null) {