summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2019-07-16 13:00:44 +0200
committerFlorian Bruhin <me@the-compiler.org>2019-07-16 13:00:44 +0200
commiteaf3efc2674f7b5de65b6c704bfdcc034482a72e (patch)
tree859290f02909a5c2e1df92665a751541aff14951
parent2d7ed87c367a4cc76d988fe36e63e5127ade67eb (diff)
downloadqutebrowser-eaf3efc2674f7b5de65b6c704bfdcc034482a72e.tar.gz
qutebrowser-eaf3efc2674f7b5de65b6c704bfdcc034482a72e.zip
Register request interceptor on GUI thread if possible.
See #4221
-rw-r--r--qutebrowser/browser/webengine/interceptor.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/qutebrowser/browser/webengine/interceptor.py b/qutebrowser/browser/webengine/interceptor.py
index 3f7618974..e95ec92b0 100644
--- a/qutebrowser/browser/webengine/interceptor.py
+++ b/qutebrowser/browser/webengine/interceptor.py
@@ -27,7 +27,7 @@ from PyQt5.QtWebEngineCore import (QWebEngineUrlRequestInterceptor,
from qutebrowser.config import config
from qutebrowser.browser import shared
-from qutebrowser.utils import utils, log, debug
+from qutebrowser.utils import utils, log, debug, qtutils
from qutebrowser.extensions import interceptors
@@ -112,17 +112,23 @@ class RequestInterceptor(QWebEngineUrlRequestInterceptor):
def install(self, profile):
"""Install the interceptor on the given QWebEngineProfile."""
- profile.setRequestInterceptor(self)
+ try:
+ # Qt >= 5.13, GUI thread
+ profile.setUrlRequestInterceptor(self)
+ except AttributeError:
+ # Qt <= 5.12, IO thread
+ profile.setRequestInterceptor(self)
# Gets called in the IO thread -> showing crash window will fail
- @utils.prevent_exceptions(None)
+ @utils.prevent_exceptions(None, not qtutils.version_check('5.13'))
def interceptRequest(self, info):
"""Handle the given request.
Reimplementing this virtual function and setting the interceptor on a
- profile makes it possible to intercept URL requests. This function is
- executed on the IO thread, and therefore running long tasks here will
- block networking.
+ profile makes it possible to intercept URL requests.
+
+ On Qt < 5.13, this function is executed on the IO thread, and therefore
+ running long tasks here will block networking.
info contains the information about the URL request and will track
internally whether its members have been altered.