[tbb-commits] [tor-browser/tor-browser-60.6.1esr-8.5-1] Bug 30214 - Kill background thread when Activity is null
gk at torproject.org
gk at torproject.org
Thu May 2 10:29:14 UTC 2019
commit 7a0a10b8ff98ebfc53fa46fb3223af0f64a97964
Author: Matthew Finkel <Matthew.Finkel at gmail.com>
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) {
More information about the tbb-commits
mailing list