Skip to content

[1256] 修复含 \< 的文档反复选中后排版引擎卡死 - #4472

Open
da-liii wants to merge 2 commits into
mainfrom
da/1256/crash
Open

[1256] 修复含 \< 的文档反复选中后排版引擎卡死#4472
da-liii wants to merge 2 commits into
mainfrom
da/1256/crash

Conversation

@da-liii

@da-liii da-liii commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

问题

打开含 <math|(m \< n)> 的文档,在公式附近反复选中/框选后,排版引擎永久卡死:UI 线程和 Qt 事件循环正常,但文档不再重绘、输入无响应。

根因

\< 解析出的公式树结构异常,拖动选中时 moebius pre_correct() 命中 TM_FAILED ("bad path") 抛出 C++ string 异常。鼠标事件走延迟路径(delayed_call_mouse_eventcommand_queue::exec_pending())时没有任何异常保护,异常穿过 s7 解释器从 qt_gui_rep::update() 逃逸,导致:

  1. updatetimer 停在停止状态、updating 永远为 true
  2. 之后所有事件只排队不再分发,排版/重绘永久停摆。

修复(双层防御,均在 qt_gui.cpp

  1. command_queue::exec_pending() 逐条 try/catch (string):失败的延时命令丢弃并继续后续命令;
  2. qt_gui_rep::update() 整体兜底 try/catch (string):无论哪一环抛异常,末尾的定时器重启与 updating=false 必然执行。

验证

修复前 4/4 轮复现(均在第一批 ~10 次操作内卡死);修复后 2 轮各 800 次混合操作全程存活,日志中 90 次 bad path 异常全部被捕获丢弃。详见 devel/1256.md

后续

\< 的规范化处理(应为 <less>)另开任务,从源头消除异常。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant