mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-15 18:12:21 +08:00
fix: 修复使用 TreeLand 混合器时启动崩溃问题
适配麒麟 CPU Wayland 环境时,强制设置环境变量 QT_WAYLAND_SHELL_INTEGRATION 为 kwayland-shell,在 TreeLand 混合器下崩溃 Log: 添加环境变量判断,DDE_CURRENT_COMPOSITER=TreeLand 或 DESKTOP_SESSION=treeland 时不执行上述设置环境变量操作
This commit is contained in:
parent
a9264b8cb9
commit
62e23facfb
96
src/main.cpp
96
src/main.cpp
@ -140,67 +140,55 @@ int main(int argc, char *argv[])
|
||||
// Set display backend
|
||||
Utils::setQPAPlatform();
|
||||
|
||||
// 龙芯机器配置,使得 DApplication 能正确加载 QTWEBENGINE
|
||||
// 龙芯机器配置,使得 DApplication 能正确加载 QtWebEngine
|
||||
qputenv("DTK_FORCE_RASTER_WIDGETS", "FALSE");
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls");
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-web-security");
|
||||
|
||||
|
||||
// 浏览器开启 GPU 支持
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls");
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-web-security");
|
||||
#ifdef __sw_64__
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
|
||||
#elif __aarch64__
|
||||
if (!Utils::isWayland()) {
|
||||
QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
||||
env = env.trimmed();
|
||||
/**
|
||||
* NOTE: 参考帮助手册代码,对于部分ARM CPU 设备,
|
||||
* --disable-gpu 保证 X11 环境下网页正常显示
|
||||
* --single-process 避免 X11 环境下 QtWebEngine 崩溃(可选)
|
||||
*/
|
||||
env += " --disable-gpu";
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
|
||||
QSurfaceFormat format;
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
||||
env = env.trimmed();
|
||||
/**
|
||||
* NOTE: 参考帮助手册代码,对于部分 ARM CPU 设备,
|
||||
* --disable-gpu 保证网页正常显示
|
||||
* --single-process 避免 QtWebEngine 崩溃(可选)
|
||||
*/
|
||||
env += " --disable-gpu";
|
||||
if (Utils::isPhytium()) {
|
||||
env += " --single-process";
|
||||
}
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
|
||||
|
||||
if (Utils::isWayland()) {
|
||||
/**
|
||||
* NOTE: https://zhuanlan.zhihu.com/p/550285855
|
||||
* 避免 X11 环境下从 QtWebEngine 后退回到 QWidget 时黑屏闪烁
|
||||
* WARNING: DDM TreeLand 混合器下,设置
|
||||
* QT_WAYLAND_SHELL_INTEGRATION 环境变量
|
||||
* 会导致崩溃 By justforlxz
|
||||
*/
|
||||
if (!Utils::isTreeLand()) {
|
||||
/**
|
||||
* NOTE: 参考帮助手册代码,对于麒麟 CPU 设备,
|
||||
* 避免 wayland 环境下 QtWebEngine 崩溃
|
||||
*/
|
||||
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "kwayland-shell");
|
||||
}
|
||||
|
||||
}
|
||||
QSurfaceFormat format;
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
|
||||
/**
|
||||
* NOTE: https://zhuanlan.zhihu.com/p/550285855
|
||||
* 避免 X11 环境下从 QtWebEngine 后退回到 QWidget 时黑屏闪烁
|
||||
*/
|
||||
if (!Utils::isWayland()) {
|
||||
qputenv("QMLSCENE_DEVICE", "softwarecontext");
|
||||
DApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
||||
}
|
||||
/**
|
||||
* FIXME: 对于麒麟 CPU 设备,调用 QtWebEngine 会导致客户端崩溃;
|
||||
* 暂时不对 CPU 进行判断,对 wayland 环境下统一处理
|
||||
*/
|
||||
else {
|
||||
QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
||||
env = env.trimmed();
|
||||
/**
|
||||
* NOTE: 参考帮助手册代码,对于麒麟 CPU 设备,
|
||||
* --disable-gpu 保证 wayland 环境下网页正常显示
|
||||
* --single-process 避免 wayland 环境下 QtWebEngine 崩溃(可选)
|
||||
*/
|
||||
env += " --disable-gpu";
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
|
||||
|
||||
/**
|
||||
* NOTE: 参考帮助手册代码,对于麒麟 CPU 设备,
|
||||
* 避免 wayland 环境下 QtWebEngine 崩溃
|
||||
*/
|
||||
qputenv("QT_WAYLAND_SHELL_INTEGRATION", "kwayland-shell");
|
||||
QSurfaceFormat format;
|
||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
}
|
||||
if (Utils::isPhytium()){
|
||||
QString env = QString::fromUtf8(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
|
||||
env = env.trimmed();
|
||||
env += " --single-process";
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", env.trimmed().toUtf8());
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -215,12 +203,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
{
|
||||
// 开启 Hidpi 支持
|
||||
qDebug() << "Enable HiDPI Support.";
|
||||
DApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
DApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
}
|
||||
// 开启 Hidpi 支持
|
||||
qDebug() << "Enable HiDPI Support.";
|
||||
DApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
DApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
// 强制使用 DTK 平台插件
|
||||
|
@ -73,6 +73,21 @@ bool Utils::isWayland()
|
||||
return isWayland;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断是否使用 TreeLand 混合器
|
||||
* @return bool true: 使用 TreeLand 混合器 false: 非 TreeLand 混合器
|
||||
*/
|
||||
bool Utils::isTreeLand()
|
||||
{
|
||||
bool isTreeLand = false;
|
||||
if (qgetenv("DDE_CURRENT_COMPOSITER").toLower() == "treeland"
|
||||
|| qgetenv("DESKTOP_SESSION").toLower() == "treeland") {
|
||||
isTreeLand = true;
|
||||
}
|
||||
|
||||
return isTreeLand;
|
||||
}
|
||||
|
||||
bool Utils::isPhytium()
|
||||
{
|
||||
bool isPhytium = false;
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
static void sendNotification(const QString &icon, const QString &title, const QString &body);
|
||||
static bool isDDE();
|
||||
static bool isWayland();
|
||||
static bool isTreeLand();
|
||||
static void initConfig();
|
||||
static bool isUOS();
|
||||
static bool isPhytium();
|
||||
|
Loading…
x
Reference in New Issue
Block a user