Skip to content

fix: remove dead DPrinter causing print preview delay - #686

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/snipefrom
pengfeixx:agent/bug/snipe-375053
Oct 23, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:release/snipefrom
pengfeixx:agent/bug/snipe-375053

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

fix: remove dead DPrinter causing print preview delay

  1. Root cause: popupPrintDialog() constructs a DPrinter(QPrinter::
    HighResolution) local variable that is never used; QPrinter
    NativeFormat construction synchronously loads the cups plugin and
    enumerates printers, blocking the UI thread for several seconds
  2. Fix: remove the dead DPrinter line introduced by commit 9fcf3e4,
    whose配套 setOutputFileName/setDocName calls were already removed
    during API migration but the constructor was left behind
  3. Impact: print preview opens faster by eliminating one redundant
    synchronous printer query; no behavior change since the variable
    was never referenced

Log: 优化打印预览页面打开速度,移除冗余的 DPrinter 构造

Influence:

  1. Test print preview opens promptly for syntax-highlighted files
  2. Verify print preview dialog functions normally (print, preview)
  3. Test print preview with plain text files

fix: 移除导致打印预览延迟的死代码 DPrinter

  1. 根因:popupPrintDialog() 中构造了 DPrinter(QPrinter::HighResolution)
    局部变量但从未使用,QPrinter NativeFormat 构造时同步加载 cups
    插件并枚举打印机,阻塞 UI 线程数秒
  2. 方案:删除由 commit 9fcf3e4 引入的死代码行,其配套的
    setOutputFileName/setDocName 调用在接口迁移中已移除,唯独构造残留
  3. 影响:打印预览打开速度提升,消除一次冗余的同步打印机查询,
    因变量从未被引用,无行为变化

Log: 优化打印预览页面打开速度,移除冗余的 DPrinter 构造

Influence:

  1. 测试语法高亮文件的打印预览打开速度
  2. 验证打印预览对话框功能正常(打印、预览)
  3. 测试纯文本文件的打印预览

PMS: BUG-375053

Summary by Sourcery

Bug Fixes:

  • Speed up print preview opening by removing an unused printer initialization that caused unnecessary synchronous printer discovery and UI blocking.

1. Root cause: popupPrintDialog() constructs a DPrinter(QPrinter::
   HighResolution) local variable that is never used; QPrinter
   NativeFormat construction synchronously loads the cups plugin and
   enumerates printers, blocking the UI thread for several seconds
2. Fix: remove the dead DPrinter line introduced by commit 9fcf3e4,
   whose配套 setOutputFileName/setDocName calls were already removed
   during API migration but the constructor was left behind
3. Impact: print preview opens faster by eliminating one redundant
   synchronous printer query; no behavior change since the variable
   was never referenced

Log: 优化打印预览页面打开速度,移除冗余的 DPrinter 构造

Influence:
1. Test print preview opens promptly for syntax-highlighted files
2. Verify print preview dialog functions normally (print, preview)
3. Test print preview with plain text files

fix: 移除导致打印预览延迟的死代码 DPrinter

1. 根因:popupPrintDialog() 中构造了 DPrinter(QPrinter::HighResolution)
   局部变量但从未使用,QPrinter NativeFormat 构造时同步加载 cups
   插件并枚举打印机,阻塞 UI 线程数秒
2. 方案:删除由 commit 9fcf3e4 引入的死代码行,其配套的
   setOutputFileName/setDocName 调用在接口迁移中已移除,唯独构造残留
3. 影响:打印预览打开速度提升,消除一次冗余的同步打印机查询,
   因变量从未被引用,无行为变化

Log: 优化打印预览页面打开速度,移除冗余的 DPrinter 构造

Influence:
1. 测试语法高亮文件的打印预览打开速度
2. 验证打印预览对话框功能正常(打印、预览)
3. 测试纯文本文件的打印预览

PMS: BUG-375053
@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The pull request removes dead DPrinter initialization from popupPrintDialog(), eliminating an unnecessary synchronous CUPS/printer query so print previews open faster without changing dialog behavior.

Sequence diagram for faster print preview opening

sequenceDiagram
    participant User
    participant Window
    participant CUPS
    participant DPrintPreviewDialog

    User->>Window: popupPrintDialog()
    Note over Window,CUPS: Before: DPrinter(QPrinter::HighResolution) synchronously queried printers
    Window->>CUPS: Enumerate printers
    CUPS-->>Window: Printer information
    Window->>DPrintPreviewDialog: new DPrintPreviewDialog(this)
    Window-->>User: Print preview opens

    User->>Window: popupPrintDialog()
    Window->>DPrintPreviewDialog: new DPrintPreviewDialog(this)
    Window-->>User: Print preview opens promptly
Loading

File-Level Changes

Change Details Files
Remove an unused high-resolution printer construction from the print-preview setup path to avoid synchronous printer backend initialization and enumeration on the UI thread.
  • Delete the unreferenced DPrinter local variable from popupPrintDialog().
  • Leave preview dialog creation and print-preview state handling unchanged.
src/widgets/window.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交移除了 popupPrintDialog() 中未使用的 DPrinter 局部变量,消除了导致打印预览延迟的无用对象创建。变更仅删除一行死代码,语法正确、逻辑清晰,不影响后续 DPrintPreviewDialog 的创建与使用,无安全风险。启发式扫描、OCR 审查均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需修改


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需修改


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: 无需修改


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: 无需修改


💡 改进建议代码示例

无需修改,当前代码已正确移除了死代码。

本报告由 AI 代码审查工具自动生成

@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 e12dd0f into linuxdeepin:release/snipe Oct 23, 2026
17 checks passed
@pengfeixx
pengfeixx deleted the agent/bug/snipe-375053 branch October 23, 2026 09:43
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