From e8450f014e099886c8cbceee64bd043094c67fc4 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 17 Sep 2024 15:57:43 +0000 Subject: [PATCH] qt gui: default to QT_QPA_PLATFORM=xcb for AppImage The wayland plugin would require at least debian 12 (or ubuntu 22.04) at runtime. see https://github.com/spesmilo/electrum/pull/9189#pullrequestreview-2309983943 : > I've now tried running the appimage on debian 10 (oldoldstable), and am getting an error with wayland. > > ``` > 4.16 | D | util.profiler | Plugins.__init__ 0.0422 sec > 4.16 | I | daemon.Daemon | launching GUI: qt > 4.76 | I | gui.qt.ElectrumGui | Qt GUI starting up... Qt=6.7.1, PyQt=6.7.1 > /tmp/.mount_electrFlGFOt/usr/bin/python3: symbol lookup error: /tmp/.mount_electrFlGFOt/usr/lib/python3.11/site-packages/PyQt6/Qt6/plugins/platforms/../../lib/libQt6WaylandClient.so.6: undefined symbol: wl_proxy_marshal_flags > ``` > > If I explicitly specify `QT_QPA_PLATFORM=xcb`, it starts and works as expected. But it picks wayland by default. > I found https://bugreports.qt.io/browse/QTBUG-114635 and it looks like even debian 11 might be affected. --- electrum/gui/qt/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/electrum/gui/qt/__init__.py b/electrum/gui/qt/__init__.py index 3ff6f9b3e..b8ab08780 100644 --- a/electrum/gui/qt/__init__.py +++ b/electrum/gui/qt/__init__.py @@ -51,6 +51,14 @@ try: except ImportError as e: pass # failure is ok; it is an optional dependency. +if sys.platform == "linux" and os.environ.get("APPIMAGE"): + # For AppImage, we default to xcb qt backend, for better support of older system. + # qt6 normally defaults to QT_QPA_PLATFORM=wayland instead of QT_QPA_PLATFORM=xcb. + # However, the wayland QPA plugin requires libwayland-client0>=1.19, which is too new + # for debian 11 or ubuntu 20.04. So instead, we default to the X11 integration (and not wayland). + # see https://bugreports.qt.io/browse/QTBUG-114635 + os.environ.setdefault("QT_QPA_PLATFORM", "xcb") + from electrum.i18n import _, set_language from electrum.plugin import run_hook from electrum.util import (UserCancelled, profiler, send_exception_to_crash_reporter,