Repository navigation
fix: reduce print preview delay by processEvents and dead code - #684
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR improves print-preview responsiveness for syntax-highlighted documents by periodically processing Qt events during full-document rehighlighting, and removes an unused printer object that unnecessarily loaded and enumerated printers. Sequence diagram for responsive print preview highlightingsequenceDiagram
participant Window
participant Preview as DPrintPreviewDialog
participant Editor as EditWrapper
participant Highlighter as QSyntaxHighlighter
participant Qt as QtEventLoop
Window->>Preview: new DPrintPreviewDialog(this)
Preview->>Editor: updateHighlighterAll()
loop Each text block
Editor->>Highlighter: rehighlightBlock(block)
opt Every 100 blocks
Editor->>Qt: processEvents()
end
end
Editor->>Highlighter: rehighlightBlock(endBlock)
Preview-->>Window: preview remains responsive
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Root cause: popupPrintDialog() constructs a DPrinter local variable (QPrinter::HighResolution) that is never used; its constructor synchronously loads the cups plugin and enumerates printers, adding avoidable latency to print preview 2. Fix: remove the unused DPrinter printer(QPrinter::HighResolution) line introduced by commit 9fcf3e4; the actual print dialog uses DPrintPreviewDialog with no arguments and builds its own printer 3. Impact: print preview opens faster by eliminating one redundant synchronous printer enumeration; no behavior change for valid print paths; no -Wunused-variable warning after removal Log: Remove dead DPrinter construction to speed up print preview Influence: 1. Test print preview with a syntax-highlighted file 2. Test print preview with a plain text file 3. Verify no unused-variable warnings in build output fix: 删除 popupPrintDialog 中无用的 DPrinter 构造 1. 根因:popupPrintDialog() 构造了一个从未使用的 DPrinter 局部 变量(QPrinter::HighResolution),其构造函数同步加载 cups 插件并枚举打印机,为打印预览增加不必要的延迟 2. 方案:删除由 commit 9fcf3e4 引入的无用 DPrinter printer( QPrinter::HighResolution) 行;实际打印对话框使用无参 DPrintPreviewDialog 并在内部自建 printer 3. 影响:消除一次冗余的同步打印机枚举,打印预览打开更快; 对有效打印路径无行为变化;删除后无 -Wunused-variable 告警 Log: 删除无用 DPrinter 构造以加速打印预览 Influence: 1. 测试语法高亮文件的打印预览 2. 测试纯文本文件的打印预览 3. 验证编译输出无 unused-variable 告警 PMS: BUG-375053
64f1130 to
ece08fc
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例本报告由 AI 代码审查工具自动生成 |
|
[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 |
|
/merge |
|
This pr cannot be merged! (status: unknown) |
fix: reduce print preview delay by processEvents and dead code
synchronously without yielding, blocking the UI thread for ~6s during
print preview of syntax-highlighted documents
responsive, matching the existing pattern in cloneLargeDocument()
variable in popupPrintDialog(), introduced by commit 9fcf3e4; its
constructor synchronously loads the cups plugin and enumerates
printers but the variable was never used
print paths, no -Wunused-variable warnings after removal
Log: Reduce print preview loading delay by adding processEvents and removing dead printer code
Influence:
fix: 减少打印预览延迟并删除死代码
事件循环,导致语法高亮文档打印预览时 UI 线程阻塞约 6 秒
cloneLargeDocument() 中已有模式一致
HighResolution) 死代码局部变量,该变量由 commit 9fcf3e4 引入,
构造时同步加载 cups 插件并枚举打印机但从未使用
-Wunused-variable 告警残留
Log: 减少打印预览加载延迟,添加 processEvents 并删除无用打印机构造
Influence:
PMS: BUG-375053
Summary by Sourcery
Improve print preview responsiveness and remove unnecessary printer initialization.
Bug Fixes:
Enhancements: