Don't set QT_HARFBUZZ with Qt >= 5.4

Fixes #1948
This commit is contained in:
Florian Bruhin 2016-09-16 08:35:17 +02:00
parent e5b3880b71
commit 43fa5f55c1

View File

@ -36,6 +36,7 @@ import traceback
import signal
import operator
import importlib
import pkg_resources
try:
import tkinter
except ImportError:
@ -141,6 +142,16 @@ def init_faulthandler(fileobj=sys.__stderr__):
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):
"""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
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!
WORKAROUND (remove this when we bump the requirements to 5.3.1)
@ -169,7 +182,6 @@ def fix_harfbuzz(args):
args: The argparse namespace.
"""
from qutebrowser.utils import log
from PyQt5.QtCore import qVersion
if 'PyQt5.QtWidgets' in sys.modules:
msg = "Harfbuzz fix attempted but QtWidgets is already imported!"
if getattr(sys, 'frozen', False):
@ -177,12 +189,14 @@ def fix_harfbuzz(args):
else:
log.init.warning(msg)
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)")
os.environ['QT_HARFBUZZ'] = 'new'
else:
elif _qt_version() < pkg_resources.parse_version('5.4.0'):
log.init.debug("Using old harfbuzz engine (auto)")
os.environ['QT_HARFBUZZ'] = 'old'
else:
log.init.debug("Using system harfbuzz engine (auto)")
elif args.harfbuzz in ['old', 'new']:
# forced harfbuzz variant
# FIXME looking at the Qt code, 'new' isn't a valid value, but leaving