fix: add null check for m_defSinkInter in sound applet#416
Merged
BLumia merged 1 commit intolinuxdeepin:masterfrom Jan 20, 2026
Merged
fix: add null check for m_defSinkInter in sound applet#416BLumia merged 1 commit intolinuxdeepin:masterfrom
BLumia merged 1 commit intolinuxdeepin:masterfrom
Conversation
Added null pointer check for m_defSinkInter before accessing its properties in removeDisabledDevice method. This prevents potential segmentation faults when the default sink interface is not properly initialized or has been destroyed. Influence: 1. Test removing disabled audio devices when m_defSinkInter is null 2. Verify sound applet stability during device hot-plug operations 3. Test audio device switching scenarios with multiple sound cards 4. Verify no crashes occur when disabling audio devices fix: 在声音小程序中添加对 m_defSinkInter 的空指针检查 在 removeDisabledDevice 方法中访问 m_defSinkInter 属性前添加了空指针检 查。这可以防止当默认接收器接口未正确初始化或已被销毁时可能发生的段错误。 Influence: 1. 测试当 m_defSinkInter 为空时移除禁用的音频设备 2. 验证在设备热插拔操作期间声音小程序的稳定性 3. 测试多声卡场景下的音频设备切换 4. 验证禁用音频设备时不会发生崩溃 PMS: BUG-347845
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a null check for the default sink interface in the sound applet’s removeDisabledDevice logic to prevent crashes when the default sink is unavailable. Sequence diagram for updated removeDisabledDevice null-safe behaviorsequenceDiagram
participant SoundApplet
participant SoundCardPort
participant DefSinkInter
SoundApplet->>SoundCardPort: compositeKey(cardId, portName)
SoundApplet->>SoundApplet: removePort(compositeKey)
alt m_defSinkInter is not null
SoundApplet->>DefSinkInter: activePort()
DefSinkInter-->>SoundApplet: Port
SoundApplet->>DefSinkInter: card()
DefSinkInter-->>SoundApplet: cardId
alt activePort.name equals portName and card equals cardId
SoundApplet->>SoundApplet: enableDevice(false)
else port or card does not match
SoundApplet->>SoundApplet: do_nothing
end
else m_defSinkInter is null
SoundApplet->>SoundApplet: skip_default_sink_check
end
Updated class diagram for SoundApplet removeDisabledDevice logicclassDiagram
class SoundApplet {
- DefSinkInter m_defSinkInter
+ enableDevice(flag bool) void
+ removeDisabledDevice(portName QString, cardId unsigned_int) void
- removePort(compositeKey QString) void
}
class SoundCardPort {
+ compositeKey(cardId unsigned_int, portName QString) QString
}
class DefSinkInter {
+ activePort() Port
+ card() unsigned_int
}
class Port {
+ name QString
}
SoundApplet --> DefSinkInter : uses
SoundApplet --> SoundCardPort : uses
DefSinkInter --> Port : returns
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review这段代码修改主要是为了防止空指针解引用(Null Pointer Dereference)导致的程序崩溃。以下是对该修改的详细审查意见: 1. 语法逻辑审查
2. 代码质量审查
3. 代码性能审查
4. 代码安全审查
5. 改进建议
6. 总结该修改是一个简单但有效的改进,显著提高了代码的健壮性和安全性。建议结合日志记录和错误处理机制,进一步完善代码的可靠性。 |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider using an early return guard (e.g.,
if (!m_defSinkInter) return;) at the top ofremoveDisabledDeviceto keep the null check separate and make the condition onactivePort().nameandcard()easier to read.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using an early return guard (e.g., `if (!m_defSinkInter) return;`) at the top of `removeDisabledDevice` to keep the null check separate and make the condition on `activePort().name` and `card()` easier to read.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
18202781743
approved these changes
Jan 19, 2026
BLumia
approved these changes
Jan 20, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia, 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 |
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.
Added null pointer check for m_defSinkInter before accessing its properties in removeDisabledDevice method. This prevents potential segmentation faults when the default sink interface is not properly initialized or has been destroyed.
Influence:
fix: 在声音小程序中添加对 m_defSinkInter 的空指针检查
在 removeDisabledDevice 方法中访问 m_defSinkInter 属性前添加了空指针检 查。这可以防止当默认接收器接口未正确初始化或已被销毁时可能发生的段错误。
Influence:
PMS: BUG-347845
Summary by Sourcery
Bug Fixes: