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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 public static AdblockEngine create(final AppInfo appInfo, 150 public static AdblockEngine create(final AppInfo appInfo,
151 final String basePath, boolean elemhideEnab led) 151 final String basePath, boolean elemhideEnab led)
152 { 152 {
153 return create(appInfo, basePath, elemhideEnabled, null, null, null, null); 153 return create(appInfo, basePath, elemhideEnabled, null, null, null, null);
154 } 154 }
155 155
156 public void dispose() 156 public void dispose()
157 { 157 {
158 Log.w(TAG, "Dispose"); 158 Log.w(TAG, "Dispose");
159 159
160 // engines first
161 if (this.filterEngine != null)
162 {
163 if (this.updateAvailableCallback != null)
164 {
165 this.filterEngine.removeUpdateAvailableCallback();
166 }
167
168 if (this.filterChangeCallback != null)
169 {
170 this.filterEngine.removeFilterChangeCallback();
171 }
172
173 if (this.showNotificationCallback != null)
174 {
175 this.filterEngine.removeShowNotificationCallback();
176 }
177
178 this.filterEngine.dispose();
179 this.filterEngine = null;
180 }
181
182 if (this.jsEngine != null)
183 {
184 this.jsEngine.dispose();
185 this.jsEngine = null;
186 }
187
188 // callbacks then
189 if (this.updateAvailableCallback != null)
190 {
191 this.updateAvailableCallback.dispose();
192 this.updateAvailableCallback = null;
193 }
194
195 if (this.filterChangeCallback != null)
196 {
197 this.filterChangeCallback.dispose();
198 this.filterChangeCallback = null;
199 }
200
201 if (this.showNotificationCallback != null)
202 {
203 this.showNotificationCallback.dispose();
204 this.showNotificationCallback = null;
205 }
206
160 if (this.logSystem != null) 207 if (this.logSystem != null)
161 { 208 {
162 this.logSystem.dispose(); 209 this.logSystem.dispose();
163 this.logSystem = null; 210 this.logSystem = null;
164 } 211 }
165 212
166 if (this.webRequest != null) 213 if (this.webRequest != null)
167 { 214 {
168 this.webRequest.dispose(); 215 this.webRequest.dispose();
169 this.webRequest = null; 216 this.webRequest = null;
170 } 217 }
171
172 if (this.updateAvailableCallback != null)
173 {
174 if (this.filterEngine != null)
175 {
176 this.filterEngine.removeUpdateAvailableCallback();
177 }
178
179 this.updateAvailableCallback.dispose();
180 this.updateAvailableCallback = null;
181 }
182
183 if (this.updateCheckDoneCallback != null)
184 {
185 this.updateCheckDoneCallback.dispose();
186 this.updateCheckDoneCallback = null;
187 }
188
189 if (this.filterChangeCallback != null)
190 {
191 if (this.filterEngine != null)
192 {
193 this.filterEngine.removeFilterChangeCallback();
194 }
195
196 this.filterChangeCallback.dispose();
197 this.filterChangeCallback = null;
198 }
199
200 if (this.showNotificationCallback != null)
201 {
202 if (this.filterEngine != null)
203 {
204 this.filterEngine.removeShowNotificationCallback();
205 }
206
207 this.showNotificationCallback.dispose();
208 this.showNotificationCallback = null;
209 }
210
211 // Safe disposing (just in case)
212 if (this.filterEngine != null)
213 {
214 this.filterEngine.dispose();
215 this.filterEngine = null;
216 }
217
218 if (this.jsEngine != null)
219 {
220 this.jsEngine.dispose();
221 this.jsEngine = null;
222 }
223 } 218 }
224 219
225 public boolean isFirstRun() 220 public boolean isFirstRun()
226 { 221 {
227 return this.filterEngine.isFirstRun(); 222 return this.filterEngine.isFirstRun();
228 } 223 }
229 224
230 public boolean isElemhideEnabled() 225 public boolean isElemhideEnabled()
231 { 226 {
232 return this.elemhideEnabled; 227 return this.elemhideEnabled;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 public void setWhitelistedDomains(List<String> domains) 459 public void setWhitelistedDomains(List<String> domains)
465 { 460 {
466 this.whitelistedDomains = domains; 461 this.whitelistedDomains = domains;
467 } 462 }
468 463
469 public List<String> getWhitelistedDomains() 464 public List<String> getWhitelistedDomains()
470 { 465 {
471 return whitelistedDomains; 466 return whitelistedDomains;
472 } 467 }
473 } 468 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld