Skip to content

fix: handle connectwidget in disconnected signal handler - #843

Draft
pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:fix/pms-249149
Draft

pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:fix/pms-249149

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

In dde-cooperation's data-transfer module, the disconnected signal handler in mainwindow_p_linux.cpp:108-119 only navigated to the error page for transferringwidget and waitwidget, missing connectwidget. When the backend daemon disconnects during the 300s connect password window, the _backendOK guard in getConnectPassWord() returns empty string, and since connectwidget is not handled by the disconnected handler, users stay on the connect page with a blank password and no error navigation. The onlineStateChanged handler (mainwindow_p_linux.cpp:97-104) already covers connectwidget separately, but the disconnected path was overlooked.

Fix

Added connectwidget to the navigation condition in the disconnected signal handler (mainwindow_p_linux.cpp:116), so when the backend disconnects while the user is on the connect page, they are redirected to errorwidget with networkError type — consistent with the existing handling for transferringwidget and waitwidget.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • Change adds one || condition branch to an existing if-statement; no signature change, no new functions, no public member changes
  • Target line is not a historical bug fix product; this change does not revert any prior fix (blame: commit ea9549f6, 2023-12-03, "fix: [disconnect] fix disconect tcp" established the handler but did not cover connectwidget)
  • No external callers affected (reference count = 0); GitNexus repo not indexed, assessment based on local code analysis

Business Impact Scope

Affects the data-transfer "准备连接" (connect) page behavior on backend disconnect. Users on the connect page during a 300s password window will now see an error page instead of a blank password. The transferringwidget, waitwidget, and onlineStateChanged paths are unaffected.

Verification Suggestion

Test the connect page after 300s with backend disconnect — verify navigation to error page with network error prompt. Regression-test transferringwidget/waitwidget disconnect navigation and onlineStateChanged connectwidget navigation.


根因分析

dde-cooperation 数据迁移模块中,mainwindow_p_linux.cpp:108-119 的 disconnected 信号处理仅对 transferringwidget 和 waitwidget 导航到错误页,遗漏 connectwidget。后端 daemon 在 300s 连接密码窗口内断开时,getConnectPassWord() 的 _backendOK 守卫返回空字符串,由于 disconnected 处理不覆盖 connectwidget,用户停留在连接页看到空白密码,无错误提示也无法刷新。onlineStateChanged 处理(mainwindow_p_linux.cpp:97-104)已独立覆盖 connectwidget,但 disconnected 路径被遗漏。

修复方案

在 disconnected 信号处理的导航条件中增加 connectwidget 分支(mainwindow_p_linux.cpp:116),后端断开时若用户在连接页则跳转到 errorwidget 并设置 networkError 类型,与现有 transferringwidget 和 waitwidget 处理一致。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 改动仅在现有 if 条件中增加一个 || 分支,不修改函数签名、不新增函数、不修改类公开成员
  • 目标行非历史修复产物,本次改动不撤销任何已有修复(blame: commit ea9549f6,2023-12-03,"fix: [disconnect] fix disconect tcp" 建立了处理逻辑但未覆盖 connectwidget)
  • 无外部调用者受影响(引用计数 = 0);GitNexus 仓库未索引,评估基于本地代码分析

业务影响范围

影响数据迁移"准备连接"页面在后端断开时的行为。用户在 300s 密码窗口内遇到后端断开时将看到错误页而非空白密码页。transferringwidget、waitwidget 和 onlineStateChanged 路径不受影响。

验证建议

测试连接页面等待 300s 后端断开时跳转错误页并显示网络错误提示。回归测试传输中页面/等待页面的断开导航行为及 onlineStateChanged 连接页面导航行为。

Summary by Sourcery

Bug Fixes:

  • Redirect the connect page to the network error page when the backend disconnects, preventing users from remaining on a blank password screen.

1. Root cause: The disconnected signal handler in mainwindow_p_linux.cpp
   only navigated to errorwidget for transferringwidget and waitwidget,
   missing connectwidget. When backend disconnects during the 300s
   connect password window, users stayed on the connect page with a
   blank password and no error navigation.
2. Fix: Add connectwidget to the navigation condition so users are
   redirected to errorwidget with networkError type on disconnect.
3. Impact: Only adds one condition branch to the existing if-statement,
   no signature change, no new functions. The onlineStateChanged handler
   already covers connectwidget separately with no conflict.

Log: Fix blank connect password page on backend disconnect during 300s wait

Influence:
1. Test connect page (connectwidget) backend disconnect after 300s,
   verify navigation to error page with network error prompt
2. Verify transferringwidget and waitwidget disconnect navigation
   behavior is unchanged
3. Verify onlineStateChanged connectwidget navigation is unaffected

fix: 修复 disconnected 信号处理中遗漏 connectwidget 分支

1. 根因:mainwindow_p_linux.cpp 的 disconnected 信号处理仅对
   transferringwidget 和 waitwidget 导航到错误页,遗漏 connectwidget。
   后端在 300s 连接密码窗口内断开时,用户停留在连接页看到空白密码,
   无错误提示也无法刷新。
2. 方案:在导航条件中增加 connectwidget 分支,后端断开时跳转到
   errorwidget 并设置 networkError 类型。
3. 影响:仅在现有 if 条件中增加一个分支,不修改函数签名、不新增
   函数。onlineStateChanged 处理已独立覆盖 connectwidget,两者无冲突。

Log: 修复连接界面等待 300s 后端断开时密码空白无错误提示的问题

Influence:
1. 测试连接页面(connectwidget)等待 300s 后端断开时跳转错误页
   并显示网络错误提示
2. 验证传输中页面和等待页面的断开导航行为不受影响
3. 验证 onlineStateChanged 对连接页面的导航行为不受影响

PMS: BUG-249149
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pppanghu77

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

@pppanghu77
pppanghu77 marked this pull request as draft October 29, 2026 19:45
@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

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

Reviewer's Guide

Updates the Linux data-transfer disconnected signal handler so backend disconnects on the connect-password page navigate to the network error page instead of leaving users on a blank connect page; existing transferring, waiting, and online-state handling remains unchanged.

Sequence diagram for connect-page backend disconnect handling

sequenceDiagram
    participant Backend
    participant MainWindowPrivate
    participant StackedWidget
    participant ErrorWidget

    Backend-->>MainWindowPrivate: disconnected()
    MainWindowPrivate->>StackedWidget: currentIndex()
    alt index == PageName.connectwidget
        MainWindowPrivate->>StackedWidget: setCurrentIndex(PageName.errorwidget)
        MainWindowPrivate->>ErrorWidget: setErrorType(ErrorType.networkError)
    end
Loading

File-Level Changes

Change Details Files
Extend backend-disconnect error navigation to cover the connect page.
  • Add connectwidget to the existing disconnected-handler page condition.
  • Redirect affected users to errorwidget with networkError, while preserving existing page handling.
src/plugins/data-transfer/core/gui/linux/mainwindow_p_linux.cpp

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

@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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/plugins/data-transfer/core/gui/linux/mainwindow_p_linux.cpp" line_range="116-117" />
<code_context>
                 if (index == PageName::errorwidget)
                     return;
-                if (index == PageName::transferringwidget || index == PageName::waitwidget)
+                if (index == PageName::transferringwidget || index == PageName::waitwidget || index == PageName::connectwidget)
                     stackedWidget->setCurrentIndex(PageName::errorwidget);
                 errorwidget->setErrorType(ErrorType::networkError);
             });
</code_context>
<issue_to_address>
**Disconnect navigation runs off GUI thread**

When a backend disconnect is emitted by the detached IPC worker thread while `connectwidget` is current, the contextless `disconnected` lambda runs in the thread emitting the signal, then calls `setCurrentIndex()` and `setErrorType()` on widgets from that thread. For the newly included connect page, this makes disconnect navigation a cross-thread widget access, so the UI can fail to update or crash.

Connect the lambda with a GUI-thread QObject context so Qt queues the widget updates to the UI thread.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +116 to 117
if (index == PageName::transferringwidget || index == PageName::waitwidget || index == PageName::connectwidget)
stackedWidget->setCurrentIndex(PageName::errorwidget);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Disconnect navigation runs off GUI thread

When a backend disconnect is emitted by the detached IPC worker thread while connectwidget is current, the contextless disconnected lambda runs in the thread emitting the signal, then calls setCurrentIndex() and setErrorType() on widgets from that thread. For the newly included connect page, this makes disconnect navigation a cross-thread widget access, so the UI can fail to update or crash.

Connect the lambda with a GUI-thread QObject context so Qt queues the widget updates to the UI thread.

Prompt for AI agents
In `src/plugins/data-transfer/core/gui/linux/mainwindow_p_linux.cpp` at lines 116-117:

**Disconnect navigation runs off GUI thread**

When a backend disconnect is emitted by the detached IPC worker thread while `connectwidget` is current, the contextless `disconnected` lambda runs in the thread emitting the signal, then calls `setCurrentIndex()` and `setErrorType()` on widgets from that thread. For the newly included connect page, this makes disconnect navigation a cross-thread widget access, so the UI can fail to update or crash.

Connect the lambda with a GUI-thread QObject context so Qt queues the widget updates to the UI thread.

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.

2 participants