parent
aa333512a1
commit
38fec3726f
|
|
@ -26,7 +26,7 @@ from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple
|
|||
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.misc import objects
|
||||
from qutebrowser.utils import usertypes, qtutils, utils
|
||||
from qutebrowser.utils import usertypes, qtutils, utils, log
|
||||
|
||||
|
||||
_ENABLE_FEATURES = '--enable-features='
|
||||
|
|
@ -266,6 +266,15 @@ def init_envvars() -> None:
|
|||
os.environ['QT_QUICK_BACKEND'] = 'software'
|
||||
elif software_rendering == 'chromium':
|
||||
os.environ['QT_WEBENGINE_DISABLE_NOUVEAU_WORKAROUND'] = '1'
|
||||
|
||||
qtwe_flags_var = 'QTWEBENGINE_CHROMIUM_FLAGS'
|
||||
qtwe_flags = os.environ.get(qtwe_flags_var)
|
||||
if qtwe_flags is not None:
|
||||
log.init.warning(
|
||||
f"You have {qtwe_flags_var}={qtwe_flags!r} set in your environment. "
|
||||
"This is currently unsupported and interferes with qutebrowser's own "
|
||||
"flag handling (including workarounds for certain crashes). "
|
||||
"Consider using the qt.args qutebrowser setting instead.")
|
||||
else:
|
||||
assert objects.backend == usertypes.Backend.QtWebKit, objects.backend
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
import pytest
|
||||
|
||||
|
|
@ -552,3 +553,29 @@ class TestEnvVars:
|
|||
monkeypatch.setattr(qtargs.objects, 'backend',
|
||||
usertypes.Backend.QtWebKit)
|
||||
qtargs.init_envvars()
|
||||
|
||||
@pytest.mark.parametrize('backend, value, expected', [
|
||||
(usertypes.Backend.QtWebKit, None, None),
|
||||
(usertypes.Backend.QtWebKit, '--test', None),
|
||||
|
||||
(usertypes.Backend.QtWebEngine, None, None),
|
||||
(usertypes.Backend.QtWebEngine, '', "''"),
|
||||
(usertypes.Backend.QtWebEngine, '--xyz', "'--xyz'"),
|
||||
])
|
||||
def test_qtwe_flags_warning(self, monkeypatch, config_stub, caplog,
|
||||
backend, value, expected):
|
||||
monkeypatch.setattr(qtargs.objects, 'backend', backend)
|
||||
if value is None:
|
||||
monkeypatch.delenv('QTWEBENGINE_CHROMIUM_FLAGS', raising=False)
|
||||
else:
|
||||
monkeypatch.setenv('QTWEBENGINE_CHROMIUM_FLAGS', value)
|
||||
|
||||
with caplog.at_level(logging.WARNING):
|
||||
qtargs.init_envvars()
|
||||
|
||||
if expected is None:
|
||||
assert not caplog.messages
|
||||
else:
|
||||
assert len(caplog.messages) == 1
|
||||
msg = caplog.messages[0]
|
||||
assert msg.startswith(f'You have QTWEBENGINE_CHROMIUM_FLAGS={expected} set')
|
||||
|
|
|
|||
Loading…
Reference in New Issue