Repository navigation
fix: prevent terminal close on custom command deletion - #590
Merged
deepin-bot[bot] merged 1 commit intoNov 11, 2026
Merged
Conversation
1. Root cause: onCustomCommandOptDlgFinished called setIsDialogShow(window(), false) unconditionally at function end, re-enabling the main window while the delete confirmation DDialog was still shown via non-blocking show(), allowing Enter key events to leak to the terminal and trigger shell exit 2. Fix: guard the setIsDialogShow(false) call with a condition that skips it when result is Rejected and a delete confirmation dialog is showing; add setIsDialogShow(false) at the end of onDeleteCustomCommandFinished to restore window state after the confirmation dialog closes 3. Impact: only the delete-confirmation path of custom command editing is affected; Accepted and plain Rejected paths keep original behavior Log: fix terminal window closing when deleting custom command via Tab+Enter Influence: 1. Test editing a custom command and saving — window state restores normally 2. Test canceling custom command edit — window state restores normally 3. Test deleting custom command via Tab+Enter — terminal window stays open 4. Test delete confirmation dialog dismiss — window state restores after fix: 修复删除自定义命令时终端窗口关闭的问题 1. 根因:onCustomCommandOptDlgFinished 在函数末尾无条件调用 setIsDialogShow(window(), false),在删除确认 DDialog 以非阻塞 show() 显示时重新启用主窗口,导致 Enter 键事件泄漏到终端触发 shell 退出 2. 方案:条件化 setIsDialogShow(false) 调用,在 Rejected 且有删除 确认对话框时跳过;在 onDeleteCustomCommandFinished 末尾补充调用 setIsDialogShow(false),确保确认对话框关闭后恢复主窗口状态 3. 影响:仅影响自定义命令编辑的删除确认路径,Accepted 和普通 Rejected 路径保持原有行为 Log: 修复通过 Tab+Enter 删除自定义命令时终端窗口关闭的问题 Influence: 1. 测试编辑自定义命令并保存 — 窗口状态恢复正常 2. 测试取消自定义命令编辑 — 窗口状态恢复正常 3. 测试通过 Tab+Enter 删除自定义命令 — 终端窗口不再关闭 4. 测试删除确认对话框关闭 — 确认后窗口状态恢复 PMS: BUG-381129
pengfeixx
marked this pull request as draft
November 6, 2026 21:53
Reviewer's GuideImplementationKeep the main window disabled while the delete confirmation is open, then restore its state when that dialog finishes.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
pengfeixx
marked this pull request as ready for review
November 11, 2026 06:37
lzwind
approved these changes
Nov 11, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, 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 |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root Cause Analysis
When editing a custom command and pressing Tab+Enter to trigger the delete button,
ListView::onCustomCommandOptDlgFinishedcallsService::instance()->setIsDialogShow(window(), false)unconditionally at the end of the function. This re-enables the main window and restores focus to the terminal while the delete confirmation DDialog (shown via non-blockingshow()) is still visible. The residual Enter key event then leaks to the terminal, gets sent as\nto the shell, and can cause the shell to exit, closing the terminal window.Key evidence:
src/views/listview.cpp:631(unconditionalsetIsDialogShow(false)) +src/views/listview.cpp:596(dlgDelete->show()non-blocking). Demo verification confirmed Enter reaches terminal in buggy version (Terminal received Enter: 1) and is blocked in fixed version (Terminal received Enter: 0).Fix
Guard the
setIsDialogShow(window(), false)call inonCustomCommandOptDlgFinishedwith a condition that skips it whenresult == Rejectedandm_pdlg->isDelCurCommand()is true (delete confirmation dialog showing). AddsetIsDialogShow(window(), false)at the end ofonDeleteCustomCommandFinishedto restore window state after the confirmation dialog closes. All other paths (Accepted, Rejected without delete) keep the original call unchanged.Change Safety Assessment
Code Safety
Business Impact Scope
Affects only the custom command delete-confirmation interaction path. Editing (Accepted) and canceling (Rejected without delete) paths keep original behavior. Users can now delete custom commands via Tab+Enter without the terminal window closing unexpectedly.
Verification Suggestion
Regression test all three paths: save custom command edit, cancel edit, and delete command via Tab+Enter — verify terminal stays open during delete confirmation and window state restores after confirmation dialog closes.
根因分析
编辑自定义命令时通过 Tab+Enter 触发删除按钮,
ListView::onCustomCommandOptDlgFinished在函数末尾无条件调用setIsDialogShow(window(), false),在删除确认 DDialog(非阻塞show()显示)仍可见时重新启用主窗口并恢复终端焦点。残余的 Enter 键事件泄漏到终端,被当作\n发送给 shell,导致 shell 退出、终端窗口关闭。关键证据:
src/views/listview.cpp:631(无条件setIsDialogShow(false))+src/views/listview.cpp:596(dlgDelete->show()非阻塞)。Demo 验证确认 BUGGY 版本 Enter 到达终端(Terminal received Enter: 1),FIXED 版本 Enter 被阻断(Terminal received Enter: 0)。修复方案
在
onCustomCommandOptDlgFinished中条件化setIsDialogShow(window(), false)调用,当result == Rejected且isDelCurCommand()为 true(删除确认对话框显示中)时跳过。在onDeleteCustomCommandFinished末尾补充调用setIsDialogShow(window(), false),确保确认对话框关闭后恢复主窗口状态。其余路径(Accepted、Rejected 无删除)保持原有调用不变。改动安全评估
代码安全评估
业务影响范围
仅影响自定义命令删除确认交互路径。编辑保存(Accepted)和取消编辑(Rejected 无删除)路径保持原有行为。用户通过 Tab+Enter 删除自定义命令时终端窗口不再意外关闭。
验证建议
回归测试三条路径:保存自定义命令编辑、取消编辑、通过 Tab+Enter 删除命令 — 验证删除确认期间终端不关闭,确认对话框关闭后窗口状态恢复。
Summary by Sourcery
Keep the main window blocked while custom command deletion is being confirmed, then restore it after the confirmation completes.
Bug Fixes: