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; |
} |
} |