OLD | NEW |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 { | 142 { |
143 for (let i = 0; i < FilterStorage.subscriptions.length; i++) | 143 for (let i = 0; i < FilterStorage.subscriptions.length; i++) |
144 { | 144 { |
145 if (FilterStorage.subscriptions[i].url == subscription.url) | 145 if (FilterStorage.subscriptions[i].url == subscription.url) |
146 { | 146 { |
147 removeSubscriptionFilters(subscription); | 147 removeSubscriptionFilters(subscription); |
148 | 148 |
149 FilterStorage.subscriptions.splice(i--, 1); | 149 FilterStorage.subscriptions.splice(i--, 1); |
150 FilterStorage.knownSubscriptions.delete(subscription.url); | 150 FilterStorage.knownSubscriptions.delete(subscription.url); |
151 FilterNotifier.triggerListeners("subscription.removed", subscription); | 151 FilterNotifier.triggerListeners("subscription.removed", subscription); |
| 152 |
| 153 // This should be the last remaining reference to the Subscription |
| 154 // object. |
| 155 Subscription.knownSubscriptions.delete(subscription.url); |
152 return; | 156 return; |
153 } | 157 } |
154 } | 158 } |
155 }, | 159 }, |
156 | 160 |
157 /** | 161 /** |
158 * Moves a subscription in the list to a new position. | 162 * Moves a subscription in the list to a new position. |
159 * @param {Subscription} subscription filter subscription to be moved | 163 * @param {Subscription} subscription filter subscription to be moved |
160 * @param {Subscription} [insertBefore] filter subscription to insert before | 164 * @param {Subscription} [insertBefore] filter subscription to insert before |
161 * (if omitted the subscription will be put at the end of the list) | 165 * (if omitted the subscription will be put at the end of the list) |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 * notifications. | 674 * notifications. |
671 * @param {Subscription} subscription filter subscription to be removed | 675 * @param {Subscription} subscription filter subscription to be removed |
672 */ | 676 */ |
673 function removeSubscriptionFilters(subscription) | 677 function removeSubscriptionFilters(subscription) |
674 { | 678 { |
675 if (!FilterStorage.knownSubscriptions.has(subscription.url)) | 679 if (!FilterStorage.knownSubscriptions.has(subscription.url)) |
676 return; | 680 return; |
677 | 681 |
678 for (let filter of subscription.filters) | 682 for (let filter of subscription.filters) |
679 { | 683 { |
680 let i = filter.subscriptions.indexOf(subscription); | 684 let index = 0; |
681 if (i >= 0) | 685 |
682 filter.subscriptions.splice(i, 1); | 686 // The same filter can occur more than once in a subscription. We could |
| 687 // avoid making duplicate subscription entries in a Filter object in |
| 688 // INIParser, but we don't do this in order to avoid slowing down the |
| 689 // loading of the initial subscriptions from disk. |
| 690 while ((index = filter.subscriptions.indexOf(subscription), index) != -1) |
| 691 filter.subscriptions.splice(index, 1); |
683 } | 692 } |
684 } | 693 } |
685 | 694 |
686 /** | 695 /** |
687 * Listener returned by FilterStorage.importData(), parses filter data. | 696 * Listener returned by FilterStorage.importData(), parses filter data. |
688 * @constructor | 697 * @constructor |
689 */ | 698 */ |
690 function INIParser() | 699 function INIParser() |
691 { | 700 { |
692 this.fileProperties = this.curObj = {}; | 701 this.fileProperties = this.curObj = {}; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 else if (this.wantObj === false && val) | 782 else if (this.wantObj === false && val) |
774 this.curObj.push(val.replace(/\\\[/g, "[")); | 783 this.curObj.push(val.replace(/\\\[/g, "[")); |
775 } | 784 } |
776 finally | 785 finally |
777 { | 786 { |
778 Filter.knownFilters = origKnownFilters; | 787 Filter.knownFilters = origKnownFilters; |
779 Subscription.knownSubscriptions = origKnownSubscriptions; | 788 Subscription.knownSubscriptions = origKnownSubscriptions; |
780 } | 789 } |
781 } | 790 } |
782 }; | 791 }; |
OLD | NEW |