summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-01-28 16:22:46 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-01-28 16:26:51 +0100
commit836047ab539be27103ad778adbd995235e86a402 (patch)
treee3b2756352614cfdec2d59306a224d2e0a3dd984
parentf3db4f21641af5f3924329e0e8b8cd27c50d466d (diff)
downloadqutebrowser-836047ab539be27103ad778adbd995235e86a402.tar.gz
qutebrowser-836047ab539be27103ad778adbd995235e86a402.zip
Handle install of adblock library during runtime
The _possibly_show_missing_dependency_warning() is only shown if the "adblock" import is unavailable (i.e. None), thus we assumed that it must be either not installed or outdated. However, there's a third possible case: The library wasn't available at import time, but it *is* available when the setting changed at runtime. If that's the case, show a warning instead of an AssertionError. (cherry picked from commit d2f0cad2c7610b62c24648db5efdfa2c7410637f)
-rw-r--r--doc/changelog.asciidoc4
-rw-r--r--qutebrowser/components/braveadblock.py8
2 files changed, 10 insertions, 2 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index de818d4b9..a70124af9 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -30,6 +30,10 @@ Fixed
file is not part of the release anymore, but if an old version is still around,
causes qutebrowser to crash. It's now explicitly blocked inside qutebrowser so
it gets ignored even if it still exists.
+- When the adblocking method was switched using `:set`, and the `adblock`
+ dependency was unavailable when qutebrowser started (but was installed while
+ qutebrowser was open), this resulted in a crash. Now a warning prompting for a
+ restart of qutebrowser is shown instead.
Changed
~~~~~~~
diff --git a/qutebrowser/components/braveadblock.py b/qutebrowser/components/braveadblock.py
index 68196255c..a851ff513 100644
--- a/qutebrowser/components/braveadblock.py
+++ b/qutebrowser/components/braveadblock.py
@@ -74,12 +74,16 @@ def _possibly_show_missing_dependency_warning() -> None:
f"Installed version {adblock_info.get_version()} of the 'adblock' "
f"dependency is too old. Minimum supported is {adblock_info.min_version}."
)
- else:
- assert not adblock_info.is_installed(), adblock_info
+ elif not adblock_info.is_installed():
message.warning(
f"Ad blocking method is set to '{method}' but 'adblock' dependency is not "
"installed."
)
+ else:
+ message.warning(
+ "The 'adblock' dependency was unavailable when qutebrowser was started, "
+ "but now seems to be installed. Please :restart qutebrowser to use it."
+ )
_RESOURCE_TYPE_STRINGS = {