Skip to content

fix(browser): fix annotation jump position in fit-to-width mode#261

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
pengfeixx:fix/annotation-jump-position
Apr 20, 2026
Merged

fix(browser): fix annotation jump position in fit-to-width mode#261
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
pengfeixx:fix/annotation-jump-position

Conversation

@pengfeixx
Copy link
Copy Markdown
Contributor

Move m_lastScaleFactor assignment after scale mode adjustment in deform() to ensure it reflects the actual rendering scale factor.

修复注释跳转位置偏下的问题,将 m_lastScaleFactor 赋值移到
缩放模式调整之后,确保使用实际渲染缩放比例计算跳转位置。

Log: 修复注释跳转位置不正确
PMS: BUG-311189
Influence: 修复在适应页宽等模式下点击注释列表跳转时,跳转位置偏下导致注释不可见的问题。

Move m_lastScaleFactor assignment after scale mode adjustment in
deform() to ensure it reflects the actual rendering scale factor.

修复注释跳转位置偏下的问题,将 m_lastScaleFactor 赋值移到
缩放模式调整之后,确保使用实际渲染缩放比例计算跳转位置。

Log: 修复注释跳转位置不正确
PMS: BUG-311189
Influence: 修复在适应页宽等模式下点击注释列表跳转时,跳转位置偏下导致注释不可见的问题。
@pengfeixx pengfeixx force-pushed the fix/annotation-jump-position branch from 2b08eba to b09b12a Compare April 20, 2026 07:09
@deepin-ci-robot
Copy link
Copy Markdown

deepin pr auto review

这段代码修改主要涉及版权年份更新和 m_lastScaleFactor 赋值位置的调整。以下是详细的审查意见和改进建议:

1. 语法逻辑审查

修改内容分析:

  • m_lastScaleFactor = operation.scaleFactor; 从函数开头移动到了 switch 语句之后。

潜在问题:

  • 逻辑风险:原代码在函数开始就保存了 scaleFactor,而修改后是在 switch 语句处理完 operation 后才保存。如果 switch 语句中修改了 operation.scaleFactor(虽然当前代码未显示这种情况),则保存的值会与传入值不同。
  • 状态一致性:如果 switch 语句中发生异常或提前返回(当前代码未显示),新位置可能导致 m_lastScaleFactor 未被更新。

建议:

  • 确认 switch 语句是否会修改 operation.scaleFactor。如果不会,当前位置是合理的;如果会,需要明确是否需要保存修改后的值。

2. 代码质量审查

优点:

  • 赋值位置更接近实际使用的上下文,提高了代码的可读性。
  • 版权年份更新符合规范。

改进建议:

  • 注释说明:建议在 m_lastScaleFactor 赋值处添加注释,说明为何在此处更新(例如:"在处理完缩放模式后更新最后的缩放因子")。
  • 变量命名operation 是一个引用参数,确保其命名能准确反映其用途(当前命名是合理的)。

3. 代码性能审查

  • 性能影响:赋值操作本身对性能影响极小,位置移动不会带来性能问题。
  • 优化建议:无需特别优化。

4. 代码安全审查

  • 线程安全:如果 SheetBrowser 类可能在多线程环境下使用,需确保 m_lastScaleFactor 的访问是线程安全的(例如使用互斥锁或原子操作)。
  • 数据一致性:确保 m_lastScaleFactor 的更新与其他相关操作(如渲染、布局计算)保持一致,避免出现状态不同步的问题。

5. 其他建议

  • 版权年份:版权年份更新为 2026 是合理的,但建议定期检查是否需要进一步更新。
  • 代码风格:保持与项目其他部分一致的代码风格(当前修改符合 Qt/C++ 常见风格)。

修改后的代码建议(添加注释):

// 在处理完缩放模式后更新最后的缩放因子
m_lastScaleFactor = operation.scaleFactor;

总结

这段修改总体是合理的,但需要确认 switch 语句是否会修改 operation.scaleFactor,并考虑线程安全问题。添加适当的注释可以提高代码的可维护性。

@deepin-ci-robot
Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pengfeixx
Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot deepin-bot Bot merged commit 940be36 into linuxdeepin:master Apr 20, 2026
10 checks passed
@pengfeixx pengfeixx deleted the fix/annotation-jump-position branch April 20, 2026 07:44
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.

3 participants