[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-60.6.1esr-8.5-1] Bug 30214 - Kill background thread when Activity is null



commit 7a0a10b8ff98ebfc53fa46fb3223af0f64a97964
Author: Matthew Finkel <Matthew.Finkel@xxxxxxxxx>
Date:   Tue Apr 30 15:29:00 2019 +0000

    Bug 30214 - Kill background thread when Activity is null
---
 .../org/mozilla/gecko/torbootstrap/TorBootstrapPanel.java | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/mobile/android/base/java/org/mozilla/gecko/torbootstrap/TorBootstrapPanel.java b/mobile/android/base/java/org/mozilla/gecko/torbootstrap/TorBootstrapPanel.java
index 2ee4c2528691..ab4de44fa8f8 100644
--- a/mobile/android/base/java/org/mozilla/gecko/torbootstrap/TorBootstrapPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/torbootstrap/TorBootstrapPanel.java
@@ -63,7 +63,10 @@ public class TorBootstrapPanel extends FirstrunPanel implements TorBootstrapLogg
         public void run() {
             while (true) {
                  synchronized(mOnionAlphaChangerLock) {
-                     if (!mOnionAlphaChangerRunning) {
+                     // Stop the animation and terminate this thread if the main thread
+                     // set |mOnionAlphaChangerRunning| to |false| or if
+                     // getActivity() returns |null|.
+                     if (!mOnionAlphaChangerRunning || getActivity() == null) {
                          // Null the reference for this thread when we exit
                          mChangeOnionAlphaThread = null;
                          return;
@@ -281,6 +284,16 @@ public class TorBootstrapPanel extends FirstrunPanel implements TorBootstrapLogg
         return mRoot;
     }
 
+    @Override
+    public void onDestroyView() {
+        // Inform the background AlphaChanging thread it should terminate.
+        synchronized(mOnionAlphaChangerLock) {
+            mOnionAlphaChangerRunning = false;
+        }
+
+        super.onDestroyView();
+    }
+
     private void setOnionAlphaValue(int newAlpha) {
         ImageView onionImg = (ImageView) mRoot.findViewById(R.id.tor_bootstrap_onion);
         if (onionImg == null) {

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits