fix: Fix displaying lock screen window when shutdown from inhibit war…#57
Merged
yixinshark merged 1 commit intolinuxdeepin:masterfrom Feb 24, 2026
Merged
Conversation
…ning page When clicking shutdown button from the inhibit warning page, doAcceptShutdownInhibit() would switch back to LockContent, causing a brief flash of the lock screen password page. Add RequireShutdown and RequireRestart to the exclusion conditions to prevent unnecessary content switching during shutdown/restart. Log: 修复从关机阻塞页面点击关机按钮会显示锁屏密码页面的问题 Pms: BUG-338545
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yixinshark 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 |
deepin-ci-robot
added a commit
to linuxdeepin/dde-session-shell-snipe
that referenced
this pull request
Feb 9, 2026
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#57
deepin pr auto review这段代码的修改主要是为了在 以下是对这段代码的详细审查和改进建议: 1. 语法逻辑审查
2. 代码质量与可读性
改进建议: 方案 A:提取辅助函数(推荐) // 在头文件中声明
bool shouldShowLockScreen() const;
// 在源文件中实现
bool WarningContent::shouldShowLockScreen() const
{
// 如果是关机或电源模式,不显示锁屏
const auto mode = m_model->currentModeState();
if (mode == SessionBaseModel::ModeStatus::ShutDownMode ||
mode == SessionBaseModel::ModeStatus::PowerMode) {
return false;
}
// 如果是任何类型的关机或重启操作,不显示锁屏
const auto action = m_powerAction;
if (action == SessionBaseModel::RequireUpdateShutdown ||
action == SessionBaseModel::RequireUpdateRestart ||
action == SessionBaseModel::RequireShutdown ||
action == SessionBaseModel::RequireRestart) {
return false;
}
return true;
}
// 调用处
void WarningContent::doAcceptShutdownInhibit()
{
if (shouldShowLockScreen()) {
FullScreenBackground::setContent(LockContent::instance());
m_model->setCurrentContentType(SessionBaseModel::LockContent);
}
}方案 B:反向逻辑(提前返回) void WarningContent::doAcceptShutdownInhibit()
{
const auto mode = m_model->currentModeState();
const auto action = m_powerAction;
// 定义不需要显示锁屏的条件
bool isPowerRelatedMode = (mode == SessionBaseModel::ModeStatus::ShutDownMode) ||
(mode == SessionBaseModel::ModeStatus::PowerMode);
bool isShutdownOrRestartAction = (action == SessionBaseModel::RequireUpdateShutdown) ||
(action == SessionBaseModel::RequireUpdateRestart) ||
(action == SessionBaseModel::RequireShutdown) ||
(action == SessionBaseModel::RequireRestart);
// 如果是电源相关模式或关机/重启动作,则直接返回,不显示锁屏
if (isPowerRelatedMode || isShutdownOrRestartAction) {
return;
}
// 剩下的情况才显示锁屏
FullScreenBackground::setContent(LockContent::instance());
m_model->setCurrentContentType(SessionBaseModel::LockContent);
}3. 代码性能
4. 代码安全
总结这段代码的修改在功能上是正确的,修复了特定场景下界面跳转的逻辑问题。但在代码质量方面,建议通过提取函数或使用局部变量配合反向逻辑来降低条件判断的复杂度,从而提高代码的可维护性。 |
18202781743
approved these changes
Feb 24, 2026
yixinshark
pushed a commit
to linuxdeepin/dde-session-shell-snipe
that referenced
this pull request
Feb 24, 2026
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#57
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.
…ning page
When clicking shutdown button from the inhibit warning page, doAcceptShutdownInhibit() would switch back to LockContent, causing a brief flash of the lock screen password page.
Add RequireShutdown and RequireRestart to the exclusion conditions to prevent unnecessary content switching during shutdown/restart.
Log: 修复从关机阻塞页面点击关机按钮会显示锁屏密码页面的问题
Pms: BUG-338545