refactor(dde-session): remove dconf dependency and fix thread safety#210
Merged
Conversation
1. Remove Dconf wrapper class (dconf.h/cpp) and its CMake references 2. Remove initSwapSched() placeholder and swap-sched-enabled check 3. Remove Dconf-based quick-black-screen logic in suspend/shutdown/reboot 4. Remove dead iowait watcher code block (was already #if 0) 5. Comment out Wayland DPMS command in setDPMSMode() Log: Remove Dconf utility class and related dead/unused code paths refactor(dde-session): 移除 Dconf 工具类及无用代码 1. 移除 Dconf 封装类(dconf.h/cpp)及其 CMake 引用 2. 移除 initSwapSched() 占位函数及 swap-sched-enabled 配置检查 3. 移除挂起/关机/重启中基于 Dconf 的 quick-black-screen 逻辑 4. 移除已禁用的 iowait watcher 代码块(原为 #if 0) 5. 注释掉 setDPMSMode() 中的 Wayland DPMS 命令 Log: 移除 Dconf 工具类及其相关的无用/未使用代码路径
1. Move session->setSessionPid/setSessionPath to main thread via QMetaObject::invokeMethod with Qt::QueuedConnection 2. Replace fifo->deleteLater() with direct delete for immediate cleanup 3. Use QueuedConnection for qApp->quit() to ensure thread-safe exit Log: Fix thread safety issues in FIFO pipe read callback by deferring session operations and app quit to the main thread event loop fix(dde-session): 修复 FIFO 管道处理中的线程安全问题 1. 通过 QMetaObject::invokeMethod(Qt::QueuedConnection) 将 setSessionPid/setSessionPath 调度到主线程执行 2. 将 fifo->deleteLater() 改为直接 delete 以立即释放资源 3. 使用 QueuedConnection 调度 qApp->quit() 确保线程安全退出 Log: 修复 FIFO 管道读取回调中的线程安全问题,将 session 操作和应用退出 调度到主线程事件循环执行
deepin pr auto review你好!我是CodeGeeX。我已经仔细审查了你提供的Git Diff。这次代码变更主要涉及:移除了自定义的 总体来说,这次重构和清理工作非常有价值,特别是线程安全方面的修复。但是,代码中仍存在一些逻辑漏洞、性能隐患以及代码规范上的问题。以下是详细的审查意见: 1. 语法与逻辑
2. 代码性能
3. 代码安全
4. 代码质量与规范
总结与修改建议代码片段针对 // main.cpp 中的线程池任务部分
QThreadPool::globalInstance()->start([&session]() {
qInfo()<< "systemd service pipe thread id: " << QThread::currentThreadId();
// ... 前置逻辑 ...
if (ok && pid > 0) {
// 使用 QPointer 防止 session 在子线程执行期间被主线程销毁导致悬空指针
QPointer<SessionManager> sessionGuard(session);
QMetaObject::invokeMethod(session, [sessionGuard, pid]() {
if (!sessionGuard) return; // 确保对象仍然存活
sessionGuard->setSessionPid(pid);
sessionGuard->setSessionPath();
}, Qt::QueuedConnection);
}
// 如果 Fifo 不是 QObject 或者没有复杂的异步关闭逻辑,delete 是可以的
delete fifo;
qInfo() << "pipe read finish, app exit.";
// 安全地在主线程退出应用
QMetaObject::invokeMethod(qApp, &QCoreApplication::quit, Qt::QueuedConnection);
});针对 void SessionManager::setDPMSMode(bool on)
{
if (Utils::IS_WAYLAND_DISPLAY) {
// 建议:不要直接注释掉,如果功能不可用,应该加宏控制或提供空实现,避免编译出无用的分支
qWarning() << "Wayland DPMS: dde_wldpms is currently disabled or unavailable.";
// EXEC_COMMAND("dde_wldpms", QStringList() << "-s" << (on ? "On" : "Off"));
} else {
// TODO 可通过Xlib发送对应请求实现此功能
EXEC_COMMAND("xset", QStringList() << "dpms" << "force" << (on ? "on" : "off"));
}
} |
yixinshark
approved these changes
Jun 3, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, 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 |
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.
Log: remove dconf dependency, clean up dead code, fix QObject thread affinity warning
refactor(dde-session): 移除 dconf 依赖并修复线程安全问题
Log: 移除 dconf 依赖,清理废弃代码,修复 QObject 线程亲和性警告