Skip to content

Commit 289a4e4

Browse files
committed
fix: improve shutdown logic and update copyright year
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
1 parent 988ce4f commit 289a4e4

File tree

3 files changed

+13
-31
lines changed

3 files changed

+13
-31
lines changed

dbus/adaptor/org.deepin.dde.SessionManager1.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<method name="CanSuspend">
1818
<arg type="b" direction="out" name="result"></arg>
1919
</method>
20-
<method name="ForceLogout"></method>
21-
<method name="ForceReboot"></method>
22-
<method name="ForceShutdown"></method>
2320
<method name="GetInhibitors">
2421
<arg name="Inhibitors" type="ao" direction="out"></arg>
2522
</method>

src/dde-session/impl/sessionmanager.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2021 - 2023 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2021 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -289,24 +289,6 @@ bool SessionManager::CanSuspend()
289289
return canSuspend == "yes";
290290
}
291291

292-
void SessionManager::ForceLogout()
293-
{
294-
qDebug() << "force logout";
295-
296-
prepareLogout(true);
297-
clearCurrentTty();
298-
doLogout();
299-
}
300-
301-
void SessionManager::ForceReboot()
302-
{
303-
reboot(true);
304-
}
305-
306-
void SessionManager::ForceShutdown()
307-
{
308-
shutdown(true);
309-
}
310292
/**
311293
* @brief SessionManager::GetInhibitors 遍历得到 Inhibitor 的路径列表,Inhibitor 是操作拦截器的意思,可以阻止一些由 flags 指定的操作。
312294
* @return ArrayofObjectPath: 返回一个包含 Inhibitors 路径名的数组
@@ -451,12 +433,12 @@ void SessionManager::RequestLogout()
451433

452434
void SessionManager::RequestReboot()
453435
{
454-
reboot(false);
436+
reboot(true);
455437
}
456438

457439
void SessionManager::RequestShutdown()
458440
{
459-
shutdown(false);
441+
shutdown(true);
460442
}
461443

462444
void SessionManager::RequestSuspend()
@@ -517,11 +499,17 @@ void SessionManager::prepareShutdown(bool force)
517499
{
518500
stopSogouIme();
519501
stopBAMFDaemon();
520-
521-
if (!force)
522-
preparePlayShutdownSound();
523-
502+
preparePlayShutdownSound();
524503
stopPulseAudioService();
504+
505+
if (force) {
506+
// 直接停止session,默认不会等待应用程序准备完成,强制关机
507+
EXEC_COMMAND("/usr/bin/dde-am"
508+
, QStringList()
509+
<< "-c"
510+
<< "/usr/libexec/dde-session-ctl"
511+
<< "--shutdown");
512+
}
525513
}
526514

527515
void SessionManager::clearCurrentTty()

src/dde-session/impl/sessionmanager.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ public Q_SLOTS:
4949
bool CanReboot();
5050
bool CanShutdown();
5151
bool CanSuspend();
52-
void ForceLogout();
53-
void ForceReboot();
54-
void ForceShutdown();
5552
QList<QDBusObjectPath> GetInhibitors();
5653
uint Inhibit(const QString &appId, uint topLevelXid, const QString &reason, uint flags);
5754
bool IsInhibited (uint flags);

0 commit comments

Comments
 (0)