Index: lib/filterStorage.js |
=================================================================== |
--- a/lib/filterStorage.js |
+++ b/lib/filterStorage.js |
@@ -144,16 +144,20 @@ |
{ |
if (FilterStorage.subscriptions[i].url == subscription.url) |
{ |
removeSubscriptionFilters(subscription); |
FilterStorage.subscriptions.splice(i--, 1); |
FilterStorage.knownSubscriptions.delete(subscription.url); |
FilterNotifier.triggerListeners("subscription.removed", subscription); |
+ |
+ // This should be the last remaining reference to the Subscription |
+ // object. |
+ Subscription.knownSubscriptions.delete(subscription.url); |
return; |
} |
} |
}, |
/** |
* Moves a subscription in the list to a new position. |
* @param {Subscription} subscription filter subscription to be moved |
@@ -672,19 +676,24 @@ |
*/ |
function removeSubscriptionFilters(subscription) |
{ |
if (!FilterStorage.knownSubscriptions.has(subscription.url)) |
return; |
for (let filter of subscription.filters) |
{ |
- let i = filter.subscriptions.indexOf(subscription); |
- if (i >= 0) |
- filter.subscriptions.splice(i, 1); |
+ let index = 0; |
+ |
+ // The same filter can occur more than once in a subscription. We could |
+ // avoid making duplicate subscription entries in a Filter object in |
+ // INIParser, but we don't do this in order to avoid slowing down the |
+ // loading of the initial subscriptions from disk. |
+ while ((index = filter.subscriptions.indexOf(subscription), index) != -1) |
+ filter.subscriptions.splice(index, 1); |
} |
} |
/** |
* Listener returned by FilterStorage.importData(), parses filter data. |
* @constructor |
*/ |
function INIParser() |