Repository navigation
Conversation
…tion 1. Root cause: IflytekAiAssistant constructor created QDBusInterface for com.deepin.copilot at init, triggering D-Bus auto-activation of uos-ai-assistant when the singleton is first accessed during startup 2. Fix: move QDBusInterface creation to ensureCopilot(), called lazily from checkValid(); valid() remains read-only on m_status 3. Impact: startup path instance()->valid() no longer touches D-Bus; AI functionality unaffected—interface created on first real use Log: Fix UOS AI window popping up when deepin-editor is set as autostart Influence: 1. Test deepin-editor autostart does not trigger UOS AI window on boot 2. Test AI features (TTS, STT, translation) work on first invocation 3. Verify no regression on normal editor startup behavior fix: 延迟创建copilot D-Bus接口避免启动时自动激活 1. 根因:IflytekAiAssistant构造函数在初始化时创建QDBusInterface 指向com.deepin.copilot,单例在启动路径首次访问时触发D-Bus 自动激活uos-ai-assistant进程 2. 方案:将QDBusInterface创建移至ensureCopilot(),由checkValid() 首次使用时懒加载;valid()保持只读m_status不触发创建 3. 影响:启动路径instance()->valid()不再触碰D-Bus;AI功能不受 影响,接口在首次实际使用时创建 Log: 修复设置文本编辑器开机自启后UOS AI窗口弹出的问题 Influence: 1. 测试设置文本编辑器开机自启后,开机不再弹出UOS AI窗口 2. 测试在文本编辑器内首次使用AI功能时仍可正常工作 3. 验证编辑器正常启动行为无回归 PMS: BUG-368911
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx 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 |
Reviewer's GuideImplementationDefer creation of the Copilot D-Bus interface from construction to
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/common/iflytek_ai_assistant.cpp" line_range="149-150" />
<code_context>
+
+QSharedPointer<QDBusInterface> IflytekAiAssistant::ensureCopilot()
+{
+ if (!m_copilot) {
+ m_copilot = QSharedPointer<QDBusInterface>::create(kCopilotService, kCopilotPath, kCopilotInterface);
+ m_copilot->setTimeout(2000);
+ }
</code_context>
<issue_to_address>
**Concurrent first use races**
When two threads invoke `checkValid()` before `m_copilot` has been initialized, both calls can read and write `m_copilot` concurrently; `QSharedPointer` does not synchronize concurrent access to the same pointer object, so the assignments race and callers can use an invalid interface or crash.
Protect lazy initialization and subsequent access to `m_copilot` with synchronization, or guarantee all calls occur on the assistant's owning thread.
</issue_to_address>| if (!m_copilot) { | ||
| m_copilot = QSharedPointer<QDBusInterface>::create(kCopilotService, kCopilotPath, kCopilotInterface); |
There was a problem hiding this comment.
🟡 Medium · Concurrent first use races
When two threads invoke checkValid() before m_copilot has been initialized, both calls can read and write m_copilot concurrently; QSharedPointer does not synchronize concurrent access to the same pointer object, so the assignments race and callers can use an invalid interface or crash.
Protect lazy initialization and subsequent access to m_copilot with synchronization, or guarantee all calls occur on the assistant's owning thread.
Prompt for AI agents
In `src/common/iflytek_ai_assistant.cpp` at lines 149-150:
**Concurrent first use races**
When two threads invoke `checkValid()` before `m_copilot` has been initialized, both calls can read and write `m_copilot` concurrently; `QSharedPointer` does not synchronize concurrent access to the same pointer object, so the assignments race and callers can use an invalid interface or crash.
Protect lazy initialization and subsequent access to `m_copilot` with synchronization, or guarantee all calls occur on the assistant's owning thread.|
TAG Bot New tag: 6.6.10 |
|
TAG Bot New tag: 6.6.11 |
|
TAG Bot New tag: 6.6.12 |
fix: lazy-create copilot D-Bus interface to avoid startup auto-activation
for com.deepin.copilot at init, triggering D-Bus auto-activation
of uos-ai-assistant when the singleton is first accessed during startup
from checkValid(); valid() remains read-only on m_status
AI functionality unaffected—interface created on first real use
Log: Fix UOS AI window popping up when deepin-editor is set as autostart
Influence:
fix: 延迟创建copilot D-Bus接口避免启动时自动激活
指向com.deepin.copilot,单例在启动路径首次访问时触发D-Bus
自动激活uos-ai-assistant进程
首次使用时懒加载;valid()保持只读m_status不触发创建
影响,接口在首次实际使用时创建
Log: 修复设置文本编辑器开机自启后UOS AI窗口弹出的问题
Influence:
PMS: BUG-368911
Summary by Sourcery
Defer Copilot D-Bus interface creation until AI functionality is actually accessed to prevent unwanted assistant activation during editor startup.
Bug Fixes:
Enhancements: