Repository navigation
Conversation
1. Root cause: when focus tab file is deleted/moved, recoverFile() skips it via continue, leaving only pending tabs added by addPendingTab which implicitly sets currentIndex to 0 with signals blocked 2. Fix: before calling activeTab(0), check if the first tab is still pending and explicitly call loadPendingTab() to load its content, bypassing the currentChanged signal dependency 3. Impact: fixes editor being uneditable after restart when exactly 2 files were open and the focus tab file was deleted; no behavior change for normal recovery paths Log: fix editor uneditable when focus tab file is deleted Influence: 1. Test opening 2 files, delete the focus file, restart editor 2. Verify editor content loads and is editable after restart 3. Test opening 3 files, delete focus file, restart editor 4. Verify normal file recovery still works correctly fix: recoverFile兜底分支显式加载待加载标签页 1. 根因:焦点标签页文件被删除/移动后,recoverFile() 通过 continue 跳过该标签页,仅剩 addPendingTab 添加的待加载标签页,其内部 隐式将 currentIndex 设为 0 但信号被阻塞 2. 方案:在调用 activeTab(0) 前,检查第一个标签页是否为待加载 状态,若是则显式调用 loadPendingTab() 加载内容,不依赖 currentChanged 信号触发 3. 影响:修复打开2个文件且焦点标签页文件被删除后重启编辑器 无法编辑的问题,不影响正常文件恢复路径 Log: 修复焦点标签页文件被删除后编辑器无法编辑的问题 Influence: 1. 测试打开2个文件,删除焦点文件后重启编辑器 2. 验证重启后编辑器内容正常加载且可编辑 3. 测试打开3个文件,删除焦点文件后重启编辑器 4. 验证正常文件恢复功能不受影响 PMS: BUG-376141
|
[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 guide (collapsed on small PRs)Reviewer's GuideFixes the recovery fallback for the two-file case where the focused file is missing: the remaining pending tab is now explicitly loaded before activation, restoring the editor content while leaving normal recovery paths unchanged. Sequence diagram for loading a pending recovery tabsequenceDiagram
participant StartManager
participant Window
participant TabBar
participant EditWrapper
StartManager->>TabBar: count()
StartManager->>TabBar: fileAt(0)
StartManager->>Window: isPendingTab(firstFile)
alt first tab is pending
StartManager->>Window: loadPendingTab(firstFile)
Window->>EditWrapper: load file content
end
StartManager->>Window: activeTab(0)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前代码已经是正确的修复方案,无需额外修改。 // 修复后的代码逻辑: // 1. 获取第一个标签页文件路径 // 2. 判断是否为 pending 标签页 // 3. 若是则显式加载,确保编辑区域有内容 // 4. 最后激活该标签页 // // QString firstFile = window->getTabbar()->fileAt(0); // if (window->isPendingTab(firstFile)) { // window->loadPendingTab(firstFile); // } // window->activeTab(0);本报告由 AI 代码审查工具自动生成 |
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/startmanager.cpp" line_range="513-515" />
<code_context>
+ // 当仅剩 pending 标签页时,currentIndex 已被 addPendingTab 隐式设为 0,
+ // activeTab(0) 中的 setCurrentIndex(0) 不会触发 currentChanged 信号,
+ // 需显式加载该 pending 标签页,否则编辑区域为空且无法编辑
+ QString firstFile = window->getTabbar()->fileAt(0);
+ if (window->isPendingTab(firstFile)) {
+ window->loadPendingTab(firstFile);
+ }
window->activeTab(0);
</code_context>
<issue_to_address>
**Earlier windows open without editors**
When the missing focus record leaves recoverable tabs in multiple saved windows, `recoverFile()` adds pending tabs to every recovery window, but this branch loads a tab only from the last `window`; earlier windows receive no `currentChanged` signal and retain unloaded tabs, so they open without file editors.
Iterate over every recovered window and explicitly load its current pending tab.
</issue_to_address>| QString firstFile = window->getTabbar()->fileAt(0); | ||
| if (window->isPendingTab(firstFile)) { | ||
| window->loadPendingTab(firstFile); |
There was a problem hiding this comment.
🟡 Medium · Earlier windows open without editors
When the missing focus record leaves recoverable tabs in multiple saved windows, recoverFile() adds pending tabs to every recovery window, but this branch loads a tab only from the last window; earlier windows receive no currentChanged signal and retain unloaded tabs, so they open without file editors.
Iterate over every recovered window and explicitly load its current pending tab.
Prompt for AI agents
In `src/startmanager.cpp` at lines 513-515:
**Earlier windows open without editors**
When the missing focus record leaves recoverable tabs in multiple saved windows, `recoverFile()` adds pending tabs to every recovery window, but this branch loads a tab only from the last `window`; earlier windows receive no `currentChanged` signal and retain unloaded tabs, so they open without file editors.
Iterate over every recovered window and explicitly load its current pending tab.|
TAG Bot New tag: 6.6.8 |
Root Cause Analysis
When the editor reopens with
recoverFile()and the focus tab's file has been deleted/moved, the focus tab is skipped viacontinue. The remaining non-focus tabs are added as pending (lazy-loaded) tabs viaaddPendingTab(), which internally callsDTabBar::setCurrentIndex(0)with signals blocked. When only 1 pending tab remains (the 2-file scenario),currentIndexis already 0, so the fallbackactiveTab(0)→setCurrentIndex(0)does not emitcurrentChanged. As a result,handleCurrentChanged()is never called,loadPendingTab()is never triggered, and the editor area has no EditWrapper — the user cannot edit.Key evidence:
addPendingTabblocks signals whileaddTabWithIndexsets currentIndex (tabbar.cpp:141);activeTabcallssetCurrentIndexwhich is a no-op when index unchanged (window.cpp:676-683).Fix
In the fallback branch of
recoverFile()(startmanager.cpp:507), before callingactiveTab(0), check whether the first tab is still pending. If so, explicitly callloadPendingTab()to load its content, bypassing thecurrentChangedsignal dependency. This is a 7-line addition using existing public interfaces (isPendingTab,loadPendingTab,getTabbar()->fileAt).Change Safety Assessment
Code Safety
loadPendingTabinternally handles file-not-found and tab-creation failures gracefullyBusiness Impact Scope
Affects the file recovery path on editor startup. Specifically fixes the scenario where exactly 2 files were open and the focus tab's file was deleted/moved before restart. No impact on normal tab switching, file opening, or multi-file recovery (3+ files).
Verification Suggestion
Test the 2-file scenario (open 2 files, delete focus file, restart) to confirm editing works. Also verify 3-file and normal recovery scenarios for no regression.
根因分析
编辑器重启时
recoverFile()恢复标签页,若焦点标签页文件已被删除/移动,则通过continue跳过。剩余非焦点标签页通过addPendingTab()以待加载(懒加载)方式添加,其内部调用DTabBar::setCurrentIndex(0)但信号被blockSignals(true)阻止。当仅剩 1 个待加载标签页(2 文件场景)时,currentIndex已为 0,兜底代码activeTab(0)→setCurrentIndex(0)不会发射currentChanged信号,导致handleCurrentChanged()永不被调用,loadPendingTab()永不触发,编辑区域无 EditWrapper,用户无法编辑。关键证据:
addPendingTab阻塞信号时addTabWithIndex已设置 currentIndex(tabbar.cpp:141);activeTab调用setCurrentIndex在索引未变时为空操作(window.cpp:676-683)。修复方案
在
recoverFile()兜底分支(startmanager.cpp:507)中,调用activeTab(0)前检查第一个标签页是否仍为待加载状态,若是则显式调用loadPendingTab()加载内容,不依赖currentChanged信号触发。新增 7 行代码,使用已有公开接口(isPendingTab、loadPendingTab、getTabbar()->fileAt)。改动安全评估
代码安全评估
loadPendingTab内部已处理文件不存在和标签创建失败的情况业务影响范围
影响编辑器启动时的文件恢复路径。专门修复打开恰好 2 个文件且焦点标签页文件被删除/移动后重启无法编辑的场景。对正常标签切换、文件打开、多文件恢复(3+ 文件)无影响。
验证建议
测试 2 文件场景(打开 2 个文件,删除焦点文件,重启)确认可正常编辑。同时验证 3 文件及正常恢复场景无回归。
Summary by Sourcery
Bug Fixes: