parent
e5b3880b71
commit
43fa5f55c1
@ -36,6 +36,7 @@ import traceback
|
|||||||
import signal
|
import signal
|
||||||
import operator
|
import operator
|
||||||
import importlib
|
import importlib
|
||||||
|
import pkg_resources
|
||||||
try:
|
try:
|
||||||
import tkinter
|
import tkinter
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -141,6 +142,16 @@ def init_faulthandler(fileobj=sys.__stderr__):
|
|||||||
faulthandler.register(signal.SIGUSR1)
|
faulthandler.register(signal.SIGUSR1)
|
||||||
|
|
||||||
|
|
||||||
|
def _qt_version():
|
||||||
|
"""Get the running Qt version.
|
||||||
|
|
||||||
|
Needs to be in a function so we can do a local import easily (to not import
|
||||||
|
from QtCore too early) but can patch this out easily for tests.
|
||||||
|
"""
|
||||||
|
from PyQt5.QtCore import qVersion
|
||||||
|
return pkg_resources.parse_version(qVersion())
|
||||||
|
|
||||||
|
|
||||||
def fix_harfbuzz(args):
|
def fix_harfbuzz(args):
|
||||||
"""Fix harfbuzz issues.
|
"""Fix harfbuzz issues.
|
||||||
|
|
||||||
@ -161,6 +172,8 @@ def fix_harfbuzz(args):
|
|||||||
- On Qt 5.3.1 this bug is fixed and the old engine will be the more stable
|
- On Qt 5.3.1 this bug is fixed and the old engine will be the more stable
|
||||||
one again.
|
one again.
|
||||||
|
|
||||||
|
- On Qt 5.4 the new engine is the default and most bugs are taken care of.
|
||||||
|
|
||||||
IMPORTANT: This needs to be done before QWidgets is imported in any way!
|
IMPORTANT: This needs to be done before QWidgets is imported in any way!
|
||||||
|
|
||||||
WORKAROUND (remove this when we bump the requirements to 5.3.1)
|
WORKAROUND (remove this when we bump the requirements to 5.3.1)
|
||||||
@ -169,7 +182,6 @@ def fix_harfbuzz(args):
|
|||||||
args: The argparse namespace.
|
args: The argparse namespace.
|
||||||
"""
|
"""
|
||||||
from qutebrowser.utils import log
|
from qutebrowser.utils import log
|
||||||
from PyQt5.QtCore import qVersion
|
|
||||||
if 'PyQt5.QtWidgets' in sys.modules:
|
if 'PyQt5.QtWidgets' in sys.modules:
|
||||||
msg = "Harfbuzz fix attempted but QtWidgets is already imported!"
|
msg = "Harfbuzz fix attempted but QtWidgets is already imported!"
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
@ -177,12 +189,14 @@ def fix_harfbuzz(args):
|
|||||||
else:
|
else:
|
||||||
log.init.warning(msg)
|
log.init.warning(msg)
|
||||||
if sys.platform.startswith('linux') and args.harfbuzz == 'auto':
|
if sys.platform.startswith('linux') and args.harfbuzz == 'auto':
|
||||||
if qVersion() == '5.3.0':
|
if _qt_version() == pkg_resources.parse_version('5.3.0'):
|
||||||
log.init.debug("Using new harfbuzz engine (auto)")
|
log.init.debug("Using new harfbuzz engine (auto)")
|
||||||
os.environ['QT_HARFBUZZ'] = 'new'
|
os.environ['QT_HARFBUZZ'] = 'new'
|
||||||
else:
|
elif _qt_version() < pkg_resources.parse_version('5.4.0'):
|
||||||
log.init.debug("Using old harfbuzz engine (auto)")
|
log.init.debug("Using old harfbuzz engine (auto)")
|
||||||
os.environ['QT_HARFBUZZ'] = 'old'
|
os.environ['QT_HARFBUZZ'] = 'old'
|
||||||
|
else:
|
||||||
|
log.init.debug("Using system harfbuzz engine (auto)")
|
||||||
elif args.harfbuzz in ['old', 'new']:
|
elif args.harfbuzz in ['old', 'new']:
|
||||||
# forced harfbuzz variant
|
# forced harfbuzz variant
|
||||||
# FIXME looking at the Qt code, 'new' isn't a valid value, but leaving
|
# FIXME looking at the Qt code, 'new' isn't a valid value, but leaving
|
||||||
|
Loading…
Reference in New Issue
Block a user