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
Conflicts:
framework/src/org/apache/cordova/CordovaChromeClient.java
diff --git a/framework/src/org/apache/cordova/CordovaChromeClient.java b/framework/src/org/apache/cordova/CordovaChromeClient.java
index 73a765f..7ae7996 100755
--- a/framework/src/org/apache/cordova/CordovaChromeClient.java
+++ b/framework/src/org/apache/cordova/CordovaChromeClient.java
@@ -71,6 +71,9 @@
// the video progress view
private View mVideoProgressView;
+ //Keep track of last AlertDialog showed
+ private AlertDialog lastHandledDialog;
+
// File Chooser
public AmazonValueCallback<Uri> mUploadMessage;
@@ -121,7 +124,7 @@
result.cancel();
}
});
- dlg.show();
+ lastHandledDialog = dlg.show();
return true;
}
@@ -162,7 +165,7 @@
result.cancel();
}
});
- dlg.show();
+ lastHandledDialog = dlg.show();
return true;
}
@@ -207,7 +210,7 @@
res.cancel();
}
});
- dlg.show();
+ lastHandledDialog = dlg.show();
}
return true;
}
@@ -374,4 +377,10 @@
}
return null;
}
+ public void destroyLastDialog(){
+ if(lastHandledDialog != null){
+ lastHandledDialog.cancel();
+ }
+ }
+
}
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index c749bd0..c2749db 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -915,6 +915,9 @@
// Load blank page so that JavaScript onunload is called
this.loadUrl("about:blank");
+
+ //Remove last AlertDialog
+ this.chromeClient.destroyLastDialog();
// Forward to plugins
if (this.pluginManager != null) {