fix: delay archive loading for non-first instance on Wayland#407
Merged
deepin-bot[bot] merged 1 commit intoMay 8, 2026
Merged
Conversation
On Wayland, the window position is set by the compositor for non-first instances. Previously the archive loading was delayed unconditionally on Wayland, causing the home page to flash. Now only non-first instances delay loading, and show the loading animation before the delay to avoid flashing. Bug: https://pms.uniontech.com/bug-view-359077.html
deepin pr auto review这段代码主要是为了修复在 Wayland 显示协议下,非首个实例窗口位置显示不正确的问题。通过引入延迟加载机制,等待窗口管理器设置好窗口位置后再显示对话框。 以下是对这段代码的详细审查意见,包括语法逻辑、代码质量、代码性能和代码安全四个方面: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 综合改进建议代码示例针对 // 在 mainwindow.cpp 中
// 定义常量
static constexpr int kWaylandDelayMs = 200;
bool MainWindow::handleArguments_Open(const QStringList &listParam)
{
// 1. 安全性改进:添加参数检查
if (listParam.isEmpty()) {
qWarning() << "Error: No file path provided to open.";
return false;
}
qInfo() << "打开文件";
m_eStartupType = StartupType::ST_Normal;
// 2. 逻辑改进:使用成员变量控制延迟
if (m_bDelayQueryDialog) {
m_bDelayQueryDialog = false; // 重置标志位
const QString &path = listParam[0]; // 使用 const引用避免拷贝
// 3. 安全性/健壮性改进:确保 LoadingPage 存在
if (m_pLoadingPage) {
m_ePageID = PI_Loading;
m_pLoadingPage->setDes(tr("Loading, please wait..."));
m_pLoadingPage->startLoading();
} else {
qWarning() << "LoadingPage is not initialized!";
// 即使没有 LoadingPage,也要尝试加载,或者做错误处理
}
// 4. 性能/逻辑改进:使用常量代替魔法数字
// 捕获 path 时,由于 path 是 const 引用,lambda 存储时最好按值捕获或确保生命周期
QTimer::singleShot(kWaylandDelayMs, [this, path]() {
// 再次检查对象有效性(可选,视具体架构而定)
loadArchive(path);
});
return true; // 或者根据实际逻辑返回
}
// ... 原有逻辑 ...
}总结这段代码的修改方向是正确的,通过引入延迟机制解决了 Wayland 环境下的窗口定位问题。 |
max-lvs
approved these changes
May 8, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: LiHua000, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/merge |
12702bc
into
linuxdeepin:develop/eagle-20260415
16 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Wayland, the window position is set by the compositor for non-first instances. Previously the archive loading was delayed unconditionally on Wayland, causing the home page to flash. Now only non-first instances delay loading, and show the loading animation before the delay to avoid flashing.
Bug: https://pms.uniontech.com/bug-view-359077.html