Repository navigation
[6026] 修复超长文档大纲侧边栏跳转最后一节异常(跳转至错误位置或视口全白) - #4738
Merged
Merged
Conversation
Co-Authored-By: Claude <[email protected]>
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.
任务背景
在极限超长文档(如
vol05.stem,14MB、1.7万页、近9万个段落)渐进式排版彻底完成后,在左侧大纲侧边栏搜索并点击最后一节“第九百五十一节:大时代!”,主文档视口未能准确定位展示目标章节,出现跳转到错误位置(如停留在前序章节/第一节)或视口完全呈现一片纯白无法渲染的缺陷。根因分析
edit_interface_rep::handle_repaint、handle_clear及draw_background接口历史遗留参数为SI x1, SI y1, SI x2, SI y2。当跳转至第 17,150+ 页文末章节时,其纵向坐标达负 220 亿(缩放后仍达负 62 亿),突破 32 位整型范围产生严重回绕(回绕至-1,936,323,328),导致draw_with_stored计算出的物理视口矩形严重偏移错位,无法命中目标页面盒。renderer_rep::encode纯虚接口与实现此前为SI& x, SI& y,内联DI重载隐式向下截断为int,导致ren->encode在转换大负坐标时发生溢出,破坏了重绘视口的裁剪盒cx/cy。在
mupdf_picture.cpp和qt_picture.cpp中,ox = pox * pixel与oy = poy * pixel为 32 位int * int乘法,在大坐标下产生溢出;同时to_qrect、to_qsize、to_qpoint中float c = 1.0 / SCREEN_PIXEL存在单精度浮点精度损失。改动内容
DI):handle_repaint、handle_clear、draw_background全面升级为DI x1, DI y1, DI x2, DI y2(同步更新 Qt / ImGui / CLI / tm_button 实现);renderer_rep::encode升级为virtual void encode (DI& x, DI& y),消除 32 位截断点;mupdf_qt_simple_widget.cpp后备缓冲拷贝坐标x1, y1, x2, y2升级为DI。mupdf_picture.cpp与qt_picture.cpp中对pox/poy进行((DI) pox) * pixel显式向上转型乘法;qt_utilities.cpp中将c = 1.0 / SCREEN_PIXEL升级为double,杜绝 64 位整型到 Qt 矩形转换时的精度损失。关键验证
python3 tests/mogan/python/6026.py:std=43.20),光标位于标题“第”字左侧正常闪烁(diff=335897),测试 PASS;xmake r 6024、xmake r 6013、xmake r 6004全部零报错通过;gf fmt --changed-since=main格式化通过。