MCSLTeam / MCSL2

MCSL2 | 一个简洁全能的Minecraft开服器
https://mcsl.com.cn
GNU General Public License v3.0
390 stars 41 forks source link

BUG|强制QT_QPA_PLATFORM=“wayland”导致使用xorg时无法启动 #62

Closed fecwaqw closed 1 year ago

fecwaqw commented 1 year ago

一般要素

问题描述

在使用xorg时因为在MCSL2.py中QT_QPA_PLATFORM环境变量被设为“wayland”而导致启动时报错

Failed to create wl_display (No such file or directory)
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

复现

使用xorg为显示服务器的Linux运行MCSL2.py

可能的解决方案(?)

加入显示服务器的判断后更改QT_QPA_PLATFORM环境变量 如将MCSL2.py的第1486行到1487行改为:

from os import environ, system
...
if system().lower() == 'linux':
    if environ["XDG_SESSION_TYPE"].lower() != 'x11':
        environ["QT_QPA_PLATFORM"] = "wayland"
...
LxHTT commented 1 year ago

已修复。