From b7abb11b0819a86d3b1b96476e7565174e286cdf Mon Sep 17 00:00:00 2001 From: zhangkun Date: Wed, 4 Mar 2026 17:12:59 +0800 Subject: [PATCH] fix: improve shutdown logic and update copyright year MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated copyright year from 2023 to 2026. Modified the prepareShutdown method to always call preparePlayShutdownSound, removing the previous conditional check based on the 'force' parameter. Added a new conditional block for forced shutdowns that executes the dde-session-ctl command with the --shutdown flag. This ensures the shutdown sound plays consistently for all shutdown types (normal and forced) and provides a proper, immediate shutdown path when force is required, bypassing application preparation delays. Log: Shutdown sound now plays during forced shutdown; forced shutdown uses a direct command for immediate termination. fix: 改进关机逻辑并更新版权年份 将版权年份从2023更新到2026。修改了prepareShutdown方法,使其总是调用 preparePlayShutdownSound,移除了之前基于'force'参数的条件判断。新增了一 个用于强制关机的条件代码块,该块会执行带有--shutdown标志的dde-session- ctl命令。这确保了关机音效在所有关机类型(正常和强制)下都能一致播放,并 在需要强制关机时提供了一条直接、立即的关机路径,绕过了应用程序的准备工作 延迟。 Log: 强制关机时现在会播放关机音效;强制关机使用直接命令实现立即终止。 PMS: BUG-281747 --- .../org.deepin.dde.SessionManager1.xml | 3 -- src/dde-session/impl/sessionmanager.cpp | 39 +++++++------------ src/dde-session/impl/sessionmanager.h | 5 +-- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/dbus/adaptor/org.deepin.dde.SessionManager1.xml b/dbus/adaptor/org.deepin.dde.SessionManager1.xml index 0467a1c..90579dc 100644 --- a/dbus/adaptor/org.deepin.dde.SessionManager1.xml +++ b/dbus/adaptor/org.deepin.dde.SessionManager1.xml @@ -17,9 +17,6 @@ - - - diff --git a/src/dde-session/impl/sessionmanager.cpp b/src/dde-session/impl/sessionmanager.cpp index 77e3ee0..43f1bf7 100644 --- a/src/dde-session/impl/sessionmanager.cpp +++ b/src/dde-session/impl/sessionmanager.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2021 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -289,24 +289,6 @@ bool SessionManager::CanSuspend() return canSuspend == "yes"; } -void SessionManager::ForceLogout() -{ - qDebug() << "force logout"; - - prepareLogout(true); - clearCurrentTty(); - doLogout(); -} - -void SessionManager::ForceReboot() -{ - reboot(true); -} - -void SessionManager::ForceShutdown() -{ - shutdown(true); -} /** * @brief SessionManager::GetInhibitors 遍历得到 Inhibitor 的路径列表,Inhibitor 是操作拦截器的意思,可以阻止一些由 flags 指定的操作。 * @return ArrayofObjectPath: 返回一个包含 Inhibitors 路径名的数组 @@ -451,12 +433,12 @@ void SessionManager::RequestLogout() void SessionManager::RequestReboot() { - reboot(false); + reboot(true); } void SessionManager::RequestShutdown() { - shutdown(false); + shutdown(true); } void SessionManager::RequestSuspend() @@ -517,11 +499,18 @@ void SessionManager::prepareShutdown(bool force) { stopSogouIme(); stopBAMFDaemon(); - - if (!force) - preparePlayShutdownSound(); - + preparePlayShutdownSound(); stopPulseAudioService(); + + if (force) { + // 直接停止session,默认不会等待应用程序准备完成,强制关机 + EXEC_COMMAND("/usr/bin/dde-am" + , QStringList() + << "-c" + << "/usr/libexec/dde-session-ctl" + << "--" + << "--shutdown"); + } } void SessionManager::clearCurrentTty() diff --git a/src/dde-session/impl/sessionmanager.h b/src/dde-session/impl/sessionmanager.h index 80a258d..c2906e8 100644 --- a/src/dde-session/impl/sessionmanager.h +++ b/src/dde-session/impl/sessionmanager.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2021 - 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -49,9 +49,6 @@ public Q_SLOTS: bool CanReboot(); bool CanShutdown(); bool CanSuspend(); - void ForceLogout(); - void ForceReboot(); - void ForceShutdown(); QList GetInhibitors(); uint Inhibit(const QString &appId, uint topLevelXid, const QString &reason, uint flags); bool IsInhibited (uint flags);