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')
|
action='store_false', dest='color')
|
||||||
parser.add_argument('-V', '--version', help="Show version and quit.",
|
parser.add_argument('-V', '--version', help="Show version and quit.",
|
||||||
action='store_true')
|
action='store_true')
|
||||||
# Note this will be checked hardcoded via sys.argv before _parse_args
|
parser.add_argument('--harfbuzz', choices=['old', 'new', 'system', 'auto'],
|
||||||
# is even run. That's also why we don't use --harfbuzz=(old|new).
|
default='auto')
|
||||||
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('command', nargs='*', help="Commands to execute on "
|
parser.add_argument('command', nargs='*', help="Commands to execute on "
|
||||||
"startup.", metavar=':command')
|
"startup.", metavar=':command')
|
||||||
# URLs will actually be in command
|
# URLs will actually be in command
|
||||||
@ -64,7 +57,7 @@ def main():
|
|||||||
"""Main entry point for qutebrowser."""
|
"""Main entry point for qutebrowser."""
|
||||||
earlyinit.init_faulthandler()
|
earlyinit.init_faulthandler()
|
||||||
args = _parse_args()
|
args = _parse_args()
|
||||||
earlyinit.fix_harfbuzz()
|
earlyinit.fix_harfbuzz(args)
|
||||||
earlyinit.check_pyqt_core()
|
earlyinit.check_pyqt_core()
|
||||||
earlyinit.check_pyqt_webkit()
|
earlyinit.check_pyqt_webkit()
|
||||||
# We do these imports late as we need to do the early init first.
|
# 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
|
# Now the faulthandler is enabled we fix the Qt harfbuzzing library, before
|
||||||
# importing any Qt stuff.
|
# importing any Qt stuff.
|
||||||
def fix_harfbuzz():
|
def fix_harfbuzz(args):
|
||||||
"""Fix harfbuzz issues.
|
"""Fix harfbuzz issues.
|
||||||
|
|
||||||
This switches to an older (but more stable) harfbuzz font rendering engine
|
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.
|
This fixes crashes on various sites.
|
||||||
See https://bugreports.qt-project.org/browse/QTBUG-36099
|
See https://bugreports.qt-project.org/browse/QTBUG-36099
|
||||||
|
|
||||||
|
Args:
|
||||||
|
args: The argparse namespace.
|
||||||
"""
|
"""
|
||||||
if (sys.platform.startswith('linux') and
|
if sys.platform.startswith('linux') and args.harfbuzz == 'auto':
|
||||||
'--system-harfbuzz' not in sys.argv):
|
|
||||||
os.environ['QT_HARFBUZZ'] = 'old'
|
os.environ['QT_HARFBUZZ'] = 'old'
|
||||||
elif '--old-harfbuzz' in sys.argv:
|
elif args.harfbuzz == 'old':
|
||||||
os.environ['QT_HARFBUZZ'] = 'old'
|
os.environ['QT_HARFBUZZ'] = 'old'
|
||||||
elif '--new-harfbuzz' in sys.argv:
|
elif args.harfbuzz == 'new':
|
||||||
os.environ['QT_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
|
# 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