Repository navigation
fix: handle connectwidget in disconnected signal handler - #843
pppanghu77 wants to merge 1 commit into
Conversation
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
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates 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 handlingsequenceDiagram
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
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 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>| if (index == PageName::transferringwidget || index == PageName::waitwidget || index == PageName::connectwidget) | ||
| stackedWidget->setCurrentIndex(PageName::errorwidget); |
There was a problem hiding this comment.
🟠 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.
Root Cause Analysis
In dde-cooperation's data-transfer module, the
disconnectedsignal handler inmainwindow_p_linux.cpp:108-119only navigated to the error page fortransferringwidgetandwaitwidget, missingconnectwidget. When the backend daemon disconnects during the 300s connect password window, the_backendOKguard ingetConnectPassWord()returns empty string, and sinceconnectwidgetis not handled by thedisconnectedhandler, users stay on the connect page with a blank password and no error navigation. TheonlineStateChangedhandler (mainwindow_p_linux.cpp:97-104) already coversconnectwidgetseparately, but thedisconnectedpath was overlooked.Fix
Added
connectwidgetto the navigation condition in thedisconnectedsignal handler (mainwindow_p_linux.cpp:116), so when the backend disconnects while the user is on the connect page, they are redirected toerrorwidgetwithnetworkErrortype — consistent with the existing handling fortransferringwidgetandwaitwidget.Change Safety Assessment
Code Safety
||condition branch to an existingif-statement; no signature change, no new functions, no public member changesea9549f6, 2023-12-03, "fix: [disconnect] fix disconect tcp" established the handler but did not coverconnectwidget)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, andonlineStateChangedpaths 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条件中增加一个||分支,不修改函数签名、不新增函数、不修改类公开成员ea9549f6,2023-12-03,"fix: [disconnect] fix disconect tcp" 建立了处理逻辑但未覆盖connectwidget)业务影响范围
影响数据迁移"准备连接"页面在后端断开时的行为。用户在 300s 密码窗口内遇到后端断开时将看到错误页而非空白密码页。
transferringwidget、waitwidget和onlineStateChanged路径不受影响。验证建议
测试连接页面等待 300s 后端断开时跳转错误页并显示网络错误提示。回归测试传输中页面/等待页面的断开导航行为及 onlineStateChanged 连接页面导航行为。
Summary by Sourcery
Bug Fixes: