From 0754a50b5bd2676cd8260599013e032ac808ed52 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 16 Nov 2023 10:25:40 +1000 Subject: [PATCH] Automatically disable sandbox on Qt5 PyPi/packaged builds --- qt/aqt/__init__.py | 12 +++++++++--- qt/aqt/qt/__init__.py | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/qt/aqt/__init__.py b/qt/aqt/__init__.py index 8709ac7b3..d3554324b 100644 --- a/qt/aqt/__init__.py +++ b/qt/aqt/__init__.py @@ -592,23 +592,29 @@ def _run(argv: Optional[list[str]] = None, exec: bool = True) -> Optional[AnkiAp # apply user-provided scale factor os.environ["QT_SCALE_FACTOR"] = str(pm.uiScale()) - # opt in to full hidpi support? + # Opt-in to full HiDPI support? if not os.environ.get("ANKI_NOHIGHDPI") and qtmajor == 5: QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_EnableHighDpiScaling) # type: ignore QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps) # type: ignore os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "1" os.environ["QT_SCALE_FACTOR_ROUNDING_POLICY"] = "PassThrough" - # Opt into software rendering. Useful for buggy systems. + # Opt-in to software rendering? if os.environ.get("ANKI_SOFTWAREOPENGL"): QCoreApplication.setAttribute(Qt.ApplicationAttribute.AA_UseSoftwareOpenGL) - # fix an issue on Windows, where Ctrl+Alt shortcuts are triggered by AltGr, + # Fix an issue on Windows, where Ctrl+Alt shortcuts are triggered by AltGr, # preventing users from typing things like "@" through AltGr+Q on a German # keyboard. if is_win and "QT_QPA_PLATFORM" not in os.environ: os.environ["QT_QPA_PLATFORM"] = "windows:altgr" + # Disable sandbox on Qt5 PyPi/packaged builds, as it causes blank screens on modern + # glibc versions. We check for specific patch versions, because distros may have + # fixed the issue in their own Qt builds. + if is_lin and qtfullversion in ([5, 15, 2], [5, 14, 1]): + os.environ["QTWEBENGINE_DISABLE_SANDBOX"] = "1" + # create the app QCoreApplication.setApplicationName("Anki") QGuiApplication.setDesktopFileName("anki.desktop") diff --git a/qt/aqt/qt/__init__.py b/qt/aqt/qt/__init__.py index 05c061b1d..2d4762f5d 100644 --- a/qt/aqt/qt/__init__.py +++ b/qt/aqt/qt/__init__.py @@ -48,6 +48,7 @@ _version = QLibraryInfo.version() qtmajor = _version.majorVersion() qtminor = _version.minorVersion() qtpoint = _version.microVersion() +qtfullversion = _version.segments() if qtmajor < 5 or (qtmajor == 5 and qtminor < 14): raise Exception("Anki does not support your Qt version.")