Repository navigation
Conversation
1. Root cause: keyPressEvent did not filter auto-repeat events for the displayshortcuts shortcut, each repeat launched a new deepin-shortcut-viewer process that killed the previous one 2. Fix: add isAutoRepeat() early-return guard before calling displayShortcuts() so only the initial key press triggers it 3. Impact: only the displayshortcuts branch is affected, no change to other shortcuts or to displayShortcuts() itself Log: 修复快捷键预览界面一闪而过的问题 Influence: 1. Test Ctrl+Shift+? shortcut preview stays visible while holding 2. Test releasing and re-pressing Ctrl+Shift+? reopens preview 3. Verify other shortcuts are unaffected fix: 修复快捷键预览界面一闪而过无法持续显示 1. 根因:keyPressEvent 未过滤 auto-repeat 事件,按住 Ctrl+Shift+? 时 每次 auto-repeat 都启动新的 deepin-shortcut-viewer 进程,新进程 杀掉旧进程导致预览界面一闪而过 2. 方案:在调用 displayShortcuts() 前添加 isAutoRepeat() 守卫,仅 首次按键触发,auto-repeat 事件直接返回 3. 影响:仅影响 displayshortcuts 分支,不改变其他快捷键行为,不 改变 displayShortcuts() 函数本身 Log: 修复快捷键预览界面一闪而过的问题 Influence: 1. 测试按住 Ctrl+Shift+? 时预览界面持续显示 2. 测试释放后再次按下 Ctrl+Shift+? 可重新打开预览 3. 验证其他快捷键功能不受影响 PMS: BUG-381385
add-uos
marked this pull request as draft
November 20, 2026 13:22
Reviewer's GuideImplementationIgnore auto-repeat key events in the displayshortcuts branch so holding the shortcut launches the preview only once.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos 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 |
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
In
Window::keyPressEvent, thedisplayshortcutsshortcut branch callsdisplayShortcuts()without checkingQKeyEvent::isAutoRepeat(). When the user holdsCtrl+Shift+?, Qt generates auto-repeatKeyPressevents at ~10–30 Hz, each triggeringdisplayShortcuts(), which in turn callsQProcess::startDetached("deepin-shortcut-viewer")every time. Multiple viewer instances compete for window focus; the newly launched instance steals focus from the previous one, causing it to close — resulting in the preview "flashing by" (source:window.cpp:4587–4589,window.cpp:2691–2692).Fix
Add an
isAutoRepeat()early-return guard before thedisplayShortcuts()call in thedisplayshortcutsbranch ofkeyPressEvent. Only the initial key press triggers the shortcut viewer; auto-repeat events are ignored. This matches the root-cause fix recommended in the analysis report (section 10).Change Safety Assessment
Code Safety
5aa177d1), not a previous bug fix — this change does not revert any historical fix.keyPressEvent) invokesdisplayShortcuts()(confirmed viagitnexus impact); no other shortcut branches or callers are affected.isAutoRepeat()is a standard Qt API since Qt4; no version compatibility risk.Business Impact Scope
The change affects only the
Ctrl+Shift+?shortcut preview feature in deepin-editor. When the user holds the key combination, the shortcut preview window (deepin-shortcut-viewer) will now stay visible instead of flashing and disappearing. All other keyboard shortcuts are unaffected. Releasing and re-pressing the key combination still reopens the preview.Verification Suggestion
Ctrl+Shift+?in deepin-editor — verify the shortcut preview stays visible.Ctrl+Shift+?— verify the preview reopens.Ctrl+S,Ctrl+O) — verify no regression.根因分析
Window::keyPressEvent的displayshortcuts快捷键分支在调用displayShortcuts()时未检查QKeyEvent::isAutoRepeat()。用户按住Ctrl+Shift+?时 Qt 以约 10–30 次/秒产生 auto-repeatKeyPress事件,每次都触发displayShortcuts(),后者每次都通过QProcess::startDetached("deepin-shortcut-viewer")启动新的预览进程。多个预览实例竞争窗口焦点,后启动的实例使前一个失去焦点而关闭,表现为预览界面"一闪而过"(证据:window.cpp:4587–4589、window.cpp:2691–2692)。修复方案
在
keyPressEvent的displayshortcuts分支、调用displayShortcuts()前增加isAutoRepeat()守卫,auto-repeat 事件直接 return,仅首次按键触发预览。与分析报告第十节方案一致。改动安全评估
代码安全评估
5aa177d1)引入,非历史 bug 修复产物,本次改动不会撤销历史修复。displayShortcuts()仅keyPressEvent一处调用(gitnexus impact确认),不影响其他快捷键分支。isAutoRepeat()为 Qt4+ 标准 API,无版本兼容风险。业务影响范围
改动仅影响 deepin-editor 的
Ctrl+Shift+?快捷键预览功能。用户按住该组合键时,快捷键预览界面(deepin-shortcut-viewer)将持续显示而非一闪而过。其他快捷键不受影响。释放后再次按下仍可重新打开预览。验证建议
Ctrl+Shift+?,验证快捷键预览界面持续显示。Ctrl+Shift+?,验证可重新打开预览。Ctrl+S、Ctrl+O),验证无回归。Summary by Sourcery
Bug Fixes: