From f6b0763f4eb973fbcc686286c0aa0887feb17a05 Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Tue, 3 Nov 2026 00:17:59 +0800 Subject: [PATCH] fix: load pending tab when focus tab file is deleted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: recoverFile() skips deleted focus tab via continue, remaining tabs added via addPendingTab() which blocks signals and calls setCurrentIndex(0) without emitting currentChanged 2. Fix: in fallback branch after activeTab(0), explicitly check if first tab is pending and call loadPendingTab() to trigger loading 3. Impact: only affects fallback path when focus tab file is missing, no behavior change for normal tab recovery flow Log: Fix unable to edit when focus tab file is deleted or moved Influence: 1. Test opening 2 files, delete focus file A, restart editor, verify file B is editable 2. Test opening 3+ files, delete focus file, restart, verify all remaining files are editable 3. Test normal multi-file restart, verify all tabs recover correctly fix: 焦点标签页文件被删除后加载待加载标签页 1. 根因:recoverFile() 通过 continue 跳过已删除的焦点标签页, 剩余标签页经 addPendingTab() 添加时阻塞信号且调用 setCurrentIndex(0) 不发射 currentChanged 信号 2. 方案:在兜底分支 activeTab(0) 之后,显式检查首个标签页是否 为待加载状态,若是则调用 loadPendingTab() 触发加载 3. 影响:仅影响焦点标签页文件缺失时的兜底路径,对正常标签页 恢复流程无行为变化 Log: 修复焦点标签页文件被删除或移动后无法编辑的问题 Influence: 1. 测试打开 2 个文件,删除焦点文件 A,重启编辑器,验证 B 文件可编辑 2. 测试打开 3+ 个文件,删除焦点文件,重启编辑器,验证所有剩余文件可编辑 3. 测试正常多文件重启,验证所有标签页正常恢复 PMS: BUG-376141 --- src/startmanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/startmanager.cpp b/src/startmanager.cpp index e615c73b..39bc9da3 100644 --- a/src/startmanager.cpp +++ b/src/startmanager.cpp @@ -509,6 +509,10 @@ int StartManager::recoverFile(Window *window) // 焦点标签页文件不存在或无焦点记录,加载第一个可用标签页 qCDebug(appLog) << "No focus tab available, loading first tab"; window->activeTab(0); + QString firstFile = window->getTabbar()->fileAt(0); + if (window->isPendingTab(firstFile)) { + window->loadPendingTab(firstFile); + } } qCInfo(appLog) << "Recovered files count:" << recFilesSum;