Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29396579: Issue 5030 - Fix the disposing order (Closed)
Patch Set: Created March 28, 2017, 8:22 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
diff --git a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
index 2b6138245dddd39e780ee5c851f7b584956c9681..0107262d47f6ac6cff3785c9b8be4431ade8c893 100644
--- a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
+++ b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
@@ -157,68 +157,63 @@ public final class AdblockEngine
{
Log.w(TAG, "Dispose");
- if (this.logSystem != null)
+ // engines first
+ if (this.filterEngine != null)
{
- this.logSystem.dispose();
- this.logSystem = null;
+ if (this.updateAvailableCallback != null)
+ {
+ this.filterEngine.removeUpdateAvailableCallback();
+ }
+
+ if (this.filterChangeCallback != null)
+ {
+ this.filterEngine.removeFilterChangeCallback();
+ }
+
+ if (this.showNotificationCallback != null)
+ {
+ this.filterEngine.removeShowNotificationCallback();
+ }
+
+ this.filterEngine.dispose();
+ this.filterEngine = null;
}
- if (this.webRequest != null)
+ if (this.jsEngine != null)
{
- this.webRequest.dispose();
- this.webRequest = null;
+ this.jsEngine.dispose();
+ this.jsEngine = null;
}
+ // callbacks then
if (this.updateAvailableCallback != null)
{
- if (this.filterEngine != null)
- {
- this.filterEngine.removeUpdateAvailableCallback();
- }
-
this.updateAvailableCallback.dispose();
this.updateAvailableCallback = null;
}
- if (this.updateCheckDoneCallback != null)
- {
- this.updateCheckDoneCallback.dispose();
- this.updateCheckDoneCallback = null;
- }
-
if (this.filterChangeCallback != null)
{
- if (this.filterEngine != null)
- {
- this.filterEngine.removeFilterChangeCallback();
- }
-
this.filterChangeCallback.dispose();
this.filterChangeCallback = null;
}
if (this.showNotificationCallback != null)
{
- if (this.filterEngine != null)
- {
- this.filterEngine.removeShowNotificationCallback();
- }
-
this.showNotificationCallback.dispose();
this.showNotificationCallback = null;
}
- // Safe disposing (just in case)
- if (this.filterEngine != null)
+ if (this.logSystem != null)
{
- this.filterEngine.dispose();
- this.filterEngine = null;
+ this.logSystem.dispose();
+ this.logSystem = null;
}
- if (this.jsEngine != null)
+ if (this.webRequest != null)
{
- this.jsEngine.dispose();
- this.jsEngine = null;
+ this.webRequest.dispose();
+ this.webRequest = null;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld