From 5fbf11c8f20d4d1aa867f82242f5804d8a3bedac Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 4 Nov 2013 16:03:11 +0100 Subject: [PATCH] AdBlock: Fix issue when enabling rule didn't work until restart. When attempting to enable rule that was already disabled on startup, it won't have an effect until completely restarting the browser. --- CHANGELOG | 2 ++ src/lib/adblock/adblockrule.cpp | 3 +++ src/lib/adblock/adblocksubscription.cpp | 10 +++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 90b05954c..aae9d8f8e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ Version 1.5.0 * added KWallet password backend plugin * added Gnome-Keyring password backend plugin * added StatusBar Icons plugin that adds extra icons to statusbar + * great performance improvement for matching basic rules in AdBlock * themes can now be loaded from profile directories * pagescreen can now save output into number of formats, including PDF * proxy exceptions now supports wildcards (*, ?) @@ -23,6 +24,7 @@ Version 1.5.0 * fixed: size of preferences dialog on low-res screens * fixed: loading plugins with relative paths in portable build * fixed: displaying a lot of RSS feeds in RSS widget in locationbar + * fixed: enabling disabled rules in AdBlock now works everytime Version 1.4.4 * released 1 September 2013 diff --git a/src/lib/adblock/adblockrule.cpp b/src/lib/adblock/adblockrule.cpp index 05a2db2ef..c068bc3a5 100644 --- a/src/lib/adblock/adblockrule.cpp +++ b/src/lib/adblock/adblockrule.cpp @@ -361,7 +361,10 @@ void AdBlockRule::parseFilter() // Empty rule or just comment if (m_filter.trimmed().isEmpty() || m_filter.startsWith(QLatin1Char('!'))) { + // We want to differentiate rule disabled by user and rule disabled in subscription file + // m_isInternalDisabled is also used when rule is disabled due to all options not being supported m_isEnabled = false; + m_isInternalDisabled = true; m_type = Invalid; return; } diff --git a/src/lib/adblock/adblocksubscription.cpp b/src/lib/adblock/adblocksubscription.cpp index 7d7d2dd4a..afa415efa 100644 --- a/src/lib/adblock/adblocksubscription.cpp +++ b/src/lib/adblock/adblocksubscription.cpp @@ -392,11 +392,19 @@ void AdBlockSubscription::populateCache() int count = m_rules.count(); for (int i = 0; i < count; ++i) { const AdBlockRule* rule = m_rules.at(i); - if (!rule->isEnabled()) { + + // Don't add internally disabled rules to cache + if (rule->isInternalDisabled()) { continue; } if (rule->isCssRule()) { + // We will add only enabled css rules to cache, because there is no enabled/disabled + // check on match. They are directly embedded to pages. + if (!rule->isEnabled()) { + continue; + } + if (rule->isDomainRestricted()) { m_domainRestrictedCssRules.append(rule); }