summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@theqtcompany.com>2015-11-30 18:50:44 +0100
committerChristian Stromme <christian.stromme@theqtcompany.com>2015-12-09 20:21:01 +0000
commit7b6d9a4cba8a4470ee346de40f6f4855fc2b2854 (patch)
tree2899b87236d6155468790cd77a09be7c806fdb0b
parentba4302894ecc511228b010ec49b9f865ea6ebe5a (diff)
Android: Explicitly tear-down the Native WebView.v5.6.0-beta1
The WebView will continue to evaluate JavaScript even after we've released all handles to the WebView, to avoid this we'll call destroy() when we release the WebView on our side. On Android 6.0 there's issued a warning when destroy is called, but this is not fatal and seems to be a know issue on their side. Alternatively, if it turns out that calling destroy() causes problems in the future, it's possible to stop JS evaluation by disabling it through the WebSettings interface. Task-number: QTBUG-49664 Change-Id: Ic98d24d58525397ad06ecbc4476cd5613b6663ab Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
-rw-r--r--src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java10
-rw-r--r--src/webview/qwebview_android.cpp7
2 files changed, 16 insertions, 1 deletions
diff --git a/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java b/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
index 2023df9..1c46847 100644
--- a/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
+++ b/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
@@ -445,4 +445,14 @@ public class QtAndroidWebViewController
final PackageManager pm = view.getContext().getPackageManager();
return pm.checkPermission("android.permission.ACCESS_FINE_LOCATION", name) == PackageManager.PERMISSION_GRANTED;
}
+
+ public void destroy()
+ {
+ m_activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ m_webView.destroy();
+ }
+ });
+ }
}
diff --git a/src/webview/qwebview_android.cpp b/src/webview/qwebview_android.cpp
index be5ab6d..f5837bc 100644
--- a/src/webview/qwebview_android.cpp
+++ b/src/webview/qwebview_android.cpp
@@ -128,8 +128,13 @@ QAndroidWebViewPrivate::QAndroidWebViewPrivate(QObject *p)
QAndroidWebViewPrivate::~QAndroidWebViewPrivate()
{
g_webViews->take(m_id);
- if (m_window != 0 && m_window->parent() == 0)
+ if (m_window != 0) {
+ m_window->setVisible(false);
+ m_window->setParent(0);
delete m_window;
+ }
+
+ m_viewController.callMethod<void>("destroy");
}
QUrl QAndroidWebViewPrivate::url() const