diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-03-18 14:28:09 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-03-18 14:28:09 +0100 |
commit | ad5381c92d1c61e726d6937f83309e9d6dfe6a22 (patch) | |
tree | 98510d2ad6101fa8d9472377edd56fc92a516c37 | |
parent | 069743e98d3dd18954298b7a10b55c5156a8d765 (diff) | |
download | qutebrowser-ad5381c92d1c61e726d6937f83309e9d6dfe6a22.tar.gz qutebrowser-ad5381c92d1c61e726d6937f83309e9d6dfe6a22.zip |
Make sure QtWebEngine is imported early
We need to import the module before a QApplication is created, so that
it can set everything up properly. This needs to happen even with the
QtWebKit backend configured, so that a proper error can be printed later
in backendproblem.py if QtWebKit is unavailable.
For QtWebEngine, this is done implicitly in qtargs.py before getting
QtWebEngine arguments.
For QtWebKit, this used to be done implicitly via version.py importing
webenginesettings, but that's not the case anymore since
fb0154ae26b09accc08c9ab7fa7cbcbe9fe2578c.
Either way, it's better to be explicit about this.
-rw-r--r-- | qutebrowser/misc/earlyinit.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/qutebrowser/misc/earlyinit.py b/qutebrowser/misc/earlyinit.py index b154eaca8..ecd3fac1a 100644 --- a/qutebrowser/misc/earlyinit.py +++ b/qutebrowser/misc/earlyinit.py @@ -279,6 +279,21 @@ def check_optimize_flag(): "unexpected behavior may occur.") +def webengine_early_import(): + """If QtWebEngine is available, import it early. + + We need to ensure that QtWebEngine is imported before a QApplication is created for + everything to work properly. + + This needs to be done even when using the QtWebKit backend, to ensure that e.g. + error messages in backendproblem.py are accurate. + """ + try: + from PyQt5 import QtWebEngineWidgets + except ImportError: + pass + + def early_init(args): """Do all needed early initialization. @@ -303,3 +318,4 @@ def early_init(args): configure_pyqt() check_ssl_support() check_optimize_flag() + webengine_early_import() |