Index: libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java |
diff --git a/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java b/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java |
index 5536696065bf2e3a6310dd9fa0ecfebede4a857a..f6522dd7c419797d0e77fdffbf65d7fff05ef04b 100644 |
--- a/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java |
+++ b/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/AdblockWebView.java |
@@ -973,11 +973,13 @@ public class AdblockWebView extends WebView |
{ |
private String selectorsString; |
private CountDownLatch finishedLatch; |
+ private AtomicBoolean isFinished; |
private AtomicBoolean isCancelled; |
public ElemHideThread(CountDownLatch finishedLatch) |
{ |
this.finishedLatch = finishedLatch; |
+ isFinished = new AtomicBoolean(false); |
isCancelled = new AtomicBoolean(false); |
} |
@@ -1053,6 +1055,7 @@ public class AdblockWebView extends WebView |
private void finish(String result) |
{ |
+ isFinished.set(true); |
d("Setting elemhide string " + result.length() + " bytes"); |
elemHideSelectorsString = result; |
onFinished(); |
@@ -1072,9 +1075,15 @@ public class AdblockWebView extends WebView |
public void cancel() |
{ |
w("Cancelling elemhide thread " + this); |
- isCancelled.set(true); |
- |
- finish(EMPTY_ELEMHIDE_ARRAY_STRING); |
+ if (!isFinished.get()) |
jens
2018/01/17 08:28:43
To make the if statement more readable, I would pr
anton
2018/01/17 08:33:55
Done. See patch set #2
|
+ { |
+ isCancelled.set(true); |
+ finish(EMPTY_ELEMHIDE_ARRAY_STRING); |
+ } |
+ else |
+ { |
+ w("This thread is finished, exiting silently " + this); |
+ } |
} |
} |