Use argparse for fix_harfbuzz
This commit is contained in:
parent
af19e6d2e5
commit
cc27d42250
@ -44,15 +44,8 @@ def _parse_args():
|
||||
action='store_false', dest='color')
|
||||
parser.add_argument('-V', '--version', help="Show version and quit.",
|
||||
action='store_true')
|
||||
# Note this will be checked hardcoded via sys.argv before _parse_args
|
||||
# is even run. That's also why we don't use --harfbuzz=(old|new).
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument('--system-harfbuzz', help="Force system harfbuzz "
|
||||
"engine", action='store_true')
|
||||
group.add_argument('--new-harfbuzz', help="Force new harfbuzz engine",
|
||||
action='store_true')
|
||||
group.add_argument('--old-harfbuzz', help="Force old harfbuzz engine",
|
||||
action='store_true')
|
||||
parser.add_argument('--harfbuzz', choices=['old', 'new', 'system', 'auto'],
|
||||
default='auto')
|
||||
parser.add_argument('command', nargs='*', help="Commands to execute on "
|
||||
"startup.", metavar=':command')
|
||||
# URLs will actually be in command
|
||||
@ -64,7 +57,7 @@ def main():
|
||||
"""Main entry point for qutebrowser."""
|
||||
earlyinit.init_faulthandler()
|
||||
args = _parse_args()
|
||||
earlyinit.fix_harfbuzz()
|
||||
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.
|
||||
|
@ -51,7 +51,7 @@ def init_faulthandler():
|
||||
|
||||
# Now the faulthandler is enabled we fix the Qt harfbuzzing library, before
|
||||
# importing any Qt stuff.
|
||||
def fix_harfbuzz():
|
||||
def fix_harfbuzz(args):
|
||||
"""Fix harfbuzz issues.
|
||||
|
||||
This switches to an older (but more stable) harfbuzz font rendering engine
|
||||
@ -59,14 +59,17 @@ def fix_harfbuzz():
|
||||
|
||||
This fixes crashes on various sites.
|
||||
See https://bugreports.qt-project.org/browse/QTBUG-36099
|
||||
|
||||
Args:
|
||||
args: The argparse namespace.
|
||||
"""
|
||||
if (sys.platform.startswith('linux') and
|
||||
'--system-harfbuzz' not in sys.argv):
|
||||
if sys.platform.startswith('linux') and args.harfbuzz == 'auto':
|
||||
os.environ['QT_HARFBUZZ'] = 'old'
|
||||
elif '--old-harfbuzz' in sys.argv:
|
||||
elif args.harfbuzz == 'old':
|
||||
os.environ['QT_HARFBUZZ'] = 'old'
|
||||
elif '--new-harfbuzz' in sys.argv:
|
||||
elif args.harfbuzz == 'new':
|
||||
os.environ['QT_HARFBUZZ'] = 'new'
|
||||
# else: use system default harfbuzz
|
||||
|
||||
|
||||
# At this point we can safely import Qt stuff, but we can't be sure it's
|
||||
|
Loading…
Reference in New Issue
Block a user