We can use QtCore in fix_harfbuzz so use logging

This commit is contained in:
Florian Bruhin 2014-06-04 23:55:34 +02:00
parent 30ce2c98e9
commit 9be3b0499d
2 changed files with 12 additions and 7 deletions

View File

@ -58,12 +58,14 @@ def main():
"""Main entry point for qutebrowser."""
earlyinit.init_faulthandler()
args = _parse_args()
earlyinit.fix_harfbuzz(args)
earlyinit.check_pyqt_core()
earlyinit.check_pyqt_webkit()
# We do these imports late as we need to do the early init first.
# We do this import late as we need to do the version checking first.
# Note we may not import webkit stuff yet as fix_harfbuzz didn't run.
import qutebrowser.utils.log as log
from qutebrowser.app import Application
log.init_log(args)
earlyinit.fix_harfbuzz(args)
earlyinit.check_pyqt_webkit()
# We do this import late as we need to fix harfbuzz first.
from qutebrowser.app import Application
app = Application(args)
return app.exec_()

View File

@ -24,7 +24,6 @@ import faulthandler
import textwrap
import traceback
import signal
import warnings
# Now we initialize the faulthandler as early as possible, so we theoretically
@ -61,11 +60,15 @@ def fix_harfbuzz(args):
This fixes crashes on various sites.
See https://bugreports.qt-project.org/browse/QTBUG-36099
IMPORTANT: This needs to be done before QWidgets is imported in any way!
Args:
args: The argparse namespace.
"""
if 'PyQt5' in sys.modules:
warnings.warn("Harfbuzz fix attempted but PyQt5 is already imported!")
from qutebrowser.utils.log import init as logger
if 'PyQt5.QtWidgets' in sys.modules:
logger.warning("Harfbuzz fix attempted but QtWidgets is already "
"imported!")
if sys.platform.startswith('linux') and args.harfbuzz == 'auto':
os.environ['QT_HARFBUZZ'] = 'old'
elif args.harfbuzz == 'old':