fix: use QPointer for default sink DBus interface#413
Conversation
1. Changed m_defaultSinkInter from raw DBusSink pointer to QPointer<DBusSink> 2. This prevents potential dangling pointer issues when the DBus object is destroyed 3. QPointer automatically becomes null when the referenced QObject is deleted 4. Improves memory safety and prevents crashes in the sound controller Influence: 1. Test sound plugin functionality after system sound service restarts 2. Verify no crashes occur when default audio sink changes 3. Test volume control and mute functionality stability 4. Verify plugin correctly handles DBus service disappearance and reappearance fix: 使用 QPointer 管理默认音频接收器的 DBus 接口 1. 将 m_defaultSinkInter 从原始 DBusSink 指针改为 QPointer<DBusSink> 2. 防止当 DBus 对象被销毁时出现悬空指针问题 3. QPointer 在被引用的 QObject 删除时会自动变为 null 4. 提高内存安全性,防止声音控制器崩溃 Influence: 1. 测试系统声音服务重启后声音插件的功能 2. 验证默认音频接收器更改时不会发生崩溃 3. 测试音量控制和静音功能的稳定性 4. 验证插件正确处理 DBus 服务消失和重新出现的情况 PMS: BUG-347199
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR replaces the raw DBusSink pointer used for the default sink interface in SoundController with a QPointer to avoid dangling pointers when the underlying QObject is destroyed, improving memory safety and crash resilience around DBus audio sink handling. Class diagram for SoundController QPointer DBusSink changeclassDiagram
class SoundController {
- DBusAudio* m_audioInter
- QPointer~DBusSink~ m_defaultSinkInter
- QSharedPointer~DConfig~ m_dconfig
}
class DBusAudio {
}
class DBusSink {
}
class DConfig {
}
class DSingleton_SoundController_ {
<<interface>>
}
SoundController ..|> DSingleton_SoundController_
SoundController --> DBusAudio : uses m_audioInter
SoundController --> DBusSink : weak_ref m_defaultSinkInter
SoundController --> DConfig : shared_ownership m_dconfig
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Now that
m_defaultSinkInteris aQPointer, please ensure all call sites defensively check for null before use and handle the DBus sink disappearing at runtime rather than assuming it is always valid. - Consider reviewing where
m_defaultSinkInteris (re)assigned to ensure it is consistently reset when the DBus service reappears so the pointer doesn’t stay null after a transient disconnect.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Now that `m_defaultSinkInter` is a `QPointer`, please ensure all call sites defensively check for null before use and handle the DBus sink disappearing at runtime rather than assuming it is always valid.
- Consider reviewing where `m_defaultSinkInter` is (re)assigned to ensure it is consistently reset when the DBus service reappears so the pointer doesn’t stay null after a transient disconnect.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review这段对这段 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与建议这是一个高质量的修改,体现了对 Qt 对象生命周期管理的正确理解。 后续建议: // 修改前可能直接调用
m_defaultSinkInter->SetVolume(...);
// 修改后建议增加判断
if (m_defaultSinkInter) {
m_defaultSinkInter->SetVolume(...);
}这样可以最大化地发挥 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, mhduiy 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 |
Influence:
fix: 使用 QPointer 管理默认音频接收器的 DBus 接口
Influence:
PMS: BUG-347199
Summary by Sourcery
Bug Fixes: