From cb0511fc1afb8a5c29afdfd113667f8efb5d2af7 Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Fri, 23 Oct 2026 14:41:43 +0800 Subject: [PATCH] fix: remove dead DPrinter causing print preview delay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 9fcf3e4c, 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 9fcf3e4c 引入的死代码行,其配套的 setOutputFileName/setDocName 调用在接口迁移中已移除,唯独构造残留 3. 影响:打印预览打开速度提升,消除一次冗余的同步打印机查询, 因变量从未被引用,无行为变化 Log: 优化打印预览页面打开速度,移除冗余的 DPrinter 构造 Influence: 1. 测试语法高亮文件的打印预览打开速度 2. 验证打印预览对话框功能正常(打印、预览) 3. 测试纯文本文件的打印预览 PMS: BUG-375053 --- src/widgets/window.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index b44006f3..fd89fd1e 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -2374,7 +2374,6 @@ void Window::popupPrintDialog() return; } - DPrinter printer(QPrinter::HighResolution); m_isNewPrint = true; m_pPreview = new DPrintPreviewDialog(this); m_pPreview->setAttribute(Qt::WA_DeleteOnClose);