cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [07/13] android commit: CB-6837 Fix leaked window when hitting back button while alert being rendered
Date Sat, 04 Oct 2014 19:32:15 GMT
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


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/890e12c3
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/890e12c3
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/890e12c3

Branch: refs/heads/master
Commit: 890e12c30674d7b4dff54082e9ee879505475e19
Parents: 6cbf6b7
Author: Martin Gonzalez <martin.c.glez.glez@gmail.com>
Authored: Fri Oct 3 00:47:13 2014 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Sat Oct 4 14:44:06 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaChromeClient.java | 16 +++++++++++++---
 .../src/org/apache/cordova/CordovaWebView.java      |  3 +++
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/890e12c3/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 737d0b8..ff0c0f2 100755
--- a/framework/src/org/apache/cordova/CordovaChromeClient.java
+++ b/framework/src/org/apache/cordova/CordovaChromeClient.java
@@ -65,6 +65,9 @@ public class CordovaChromeClient extends WebChromeClient {
     // the video progress view
     private View mVideoProgressView;
     
+    //Keep track of last AlertDialog showed
+    private AlertDialog lastHandledDialog;
+    
     // File Chooser
     public ValueCallback<Uri> mUploadMessage;
     
@@ -123,7 +126,7 @@ public class CordovaChromeClient extends WebChromeClient {
                     return true;
             }
         });
-        dlg.show();
+        lastHandledDialog = dlg.show();
         return true;
     }
 
@@ -172,7 +175,7 @@ public class CordovaChromeClient extends WebChromeClient {
                     return true;
             }
         });
-        dlg.show();
+        lastHandledDialog = dlg.show();
         return true;
     }
 
@@ -216,7 +219,7 @@ public class CordovaChromeClient extends WebChromeClient {
                             res.cancel();
                         }
                     });
-            dlg.show();
+            lastHandledDialog = dlg.show();
         }
         return true;
     }
@@ -328,4 +331,11 @@ public class CordovaChromeClient extends WebChromeClient {
     public ValueCallback<Uri> getValueCallback() {
         return this.mUploadMessage;
     }
+    
+    public void destroyLastDialog(){
+        if(lastHandledDialog != null){
+                lastHandledDialog.cancel();
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/890e12c3/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index f7a94ae..862f2de 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -788,6 +788,9 @@ public class CordovaWebView extends WebView {
 
         // 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) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message