Skip to content

fix(editor): remove redundant audio device disabled toast on each tab - #519

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
tianming-1996:fix/bug-373361
Aug 13, 2026
Merged

fix(editor): remove redundant audio device disabled toast on each tab#519
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/eaglefrom
tianming-1996:fix/bug-373361

Conversation

@tianming-1996

@tianming-1996 tianming-1996 commented Aug 13, 2026

Copy link
Copy Markdown

根因分析

每个标签页对应的 TextEdit 在构造函数(src/editor/dtextedit.cpp:143-146)中订阅了音频守护进程 com.deepin.daemon.AudioPortEnabledChanged 信号,并在回调 onAudioPortEnabledChangeddtextedit.cpp:8280-8316)中于设备被禁用时主动向自身弹浮窗提示。N 个标签页 = N 个订阅者,因此控制中心禁用设备时每个标签页各弹一次"未检测到音频输出/输入设备"提示,与 bug 现象"多标签页均提示"一致。该逻辑由提交 c0461e00(Task 378245)引入,后续 04a5e042(Bug 323813)仅改按需路径,未触及本路径,release/eagle HEAD 仍存在。

修复方案

移除"主动监听并弹窗"的路径,保留"用户主动点击语音功能时的按需检查":

  1. 删除 dtextedit.cpp 构造函数中对 PortEnabledChanged 的 DBus 订阅。
  2. 删除 onAudioPortEnabledChanged 槽函数实现及其在头文件的声明。
  3. 保留 checkAudioOutputDevice()/checkAudioInputDevice() 及其在 slotVoiceReadingAction/slotdictationAction 中的按需调用——用户主动点击语音朗读/听写时仍会给出"无设备"提示。

按需路径与主动弹窗路径完全独立:checkAudio*Device() 是同步 DBus 方法调用,不依赖被删除的信号;onAudioPortEnabledChanged 回调体内不含任何 dbus-send/QProcess/TextToSpeech 调用,从不启动或控制朗读。

改动安全评估

低风险。onAudioPortEnabledChanged 仅被本类构造函数内部的 DBus 订阅使用,全仓库无第三个引用点(reference_count=2,均为本次删除对象)。删除订阅与删除声明成对进行,内部自洽,无外部调用者受影响。不修改任何函数签名,不触碰保留的按需检查与语音朗读/听写执行链路。

PMS: BUG-373361

Summary by Sourcery

Remove automatic audio device state monitoring in the editor to avoid duplicate device-disabled toasts across multiple tabs while preserving on-demand checks when users trigger voice features.

Bug Fixes:

  • Eliminate redundant audio device disabled notifications by removing per-tab subscriptions to the audio daemon’s PortEnabledChanged signal.

Enhancements:

  • Simplify TextEdit audio handling by deleting the unused audio port state change slot and relying solely on existing on-demand device checks.

When audio devices are disabled via control center, each TextEdit
instance (tab) subscribes to com.deepin.daemon.Audio PortEnabledChanged
signal and proactively shows a "no audio device" float message. With N
tabs open, N toasts fire simultaneously, which is unwanted.

The on-demand device checks in slotVoiceReadingAction and
slotdictationAction remain intact, so the user still gets a prompt
when actively clicking voice reading or dictation.

音频设备被禁用时,每个标签页主动弹出"无音频设备"提示,多标签页
重复弹窗不符合预期。移除构造函数的 PortEnabledChanged 信号订阅
和 onAudioPortEnabledChanged 槽函数,保留按需设备检查。

Log: 移除音频设备禁用时每个标签页主动弹出提示的逻辑
PMS: BUG-373361
Influence: 控制中心禁用音频设备后,文本编辑器不再向所有标签页弹出"无音频设备"提示;用户主动点击语音朗读/听写时的按需提示不受影响
@sourcery-ai

sourcery-ai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the per-tab DBus subscription to the audio daemon’s PortEnabledChanged signal and its handler, leaving only the on-demand audio device checks triggered by voice reading/dictation actions so that disabling devices no longer spams a toast on every open editor tab.

File-Level Changes

Change Details Files
Remove automatic audio device status listening and toast handling from TextEdit, keeping only on-demand device checks when the user triggers voice features.
  • Deleted the DBus sessionBus().connect call to com.deepin.daemon.Audio PortEnabledChanged in the TextEdit constructor to stop registering one signal listener per tab.
  • Removed the onAudioPortEnabledChanged slot implementation that reacted to PortEnabledChanged by checking devices and showing warning toasts.
  • Removed the onAudioPortEnabledChanged slot declaration from the TextEdit public slots section, ensuring no leftover references.
  • Left checkAudioOutputDevice/checkAudioInputDevice and their usage from voice reading/dictation actions intact so audio availability is still validated when needed.
src/editor/dtextedit.cpp
src/editor/dtextedit.h

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码成功移除了文本编辑器中越权的音频设备热插拔监听逻辑,降低了模块耦合度
逻辑完全正确且清理了冗余代码,无任何扣分项

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓
    移除的代码包括 dtextedit.cpp 构造函数中的 DBus 信号连接、槽函数实现 TextEdit::onAudioPortEnabledChanged 以及 dtextedit.h 中的对应声明。删除动作彻底,未遗留悬空引用或未定义的信号槽连接,保留的 checkAudioOutputDevicecheckAudioInputDevice 未受影响。
    建议:无需改进,清理工作非常干净。
  • 2.代码质量(良好)✓
    文本编辑器核心组件不应承担底层音频设备状态监听的职责,原逻辑属于越权干预。此次移除有效遵循了单一职责原则,消除了编辑器对 com.deepin.daemon.Audio DBus 接口的不合理依赖,同时清理了头文件中多余的空行和注释。
    建议:无需改进。
  • 3.代码性能(高效)✓
    移除了对系统级 DBus 信号 PortEnabledChanged 的监听,避免了在系统音频设备频繁插拔时触发文本编辑器进程上下文切换及后续的设备检测和 UI 渲染操作,降低了不必要的系统调用开销。
    建议:无需改进。
  • 4.代码安全(存在0个安全漏洞)✓
    漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
    本次变更为纯删除操作,未引入任何新的安全风险。相反,移除 DBus 信号监听实际上收窄了攻击面,消除了外部进程通过伪造或高频发送 PortEnabledChanged 信号对文本编辑器进行拒绝服务攻击(如导致 UI 线程被大量浮窗消息阻塞)的可能性。
  • 建议:继续保持精简的依赖树,避免在非系统级设置工具中引入底层硬件状态监听。

■ 【改进建议代码示例】

// 无需改进,当前 diff 即为最佳实践。
// 移除越权的 DBus 监听逻辑,保持文本编辑器的纯粹性。
// 若后续确实需要提示用户音频设备异常,应通过系统级全局通知机制统一处理,
// 而非在单个应用内通过 DBus 直连底层 daemon 弹窗。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: max-lvs, tianming-1996

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tianming-1996

Copy link
Copy Markdown
Author

/merge

@deepin-bot
deepin-bot Bot merged commit 733baf0 into linuxdeepin:release/eagle Aug 13, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants